Skip to content

Commit 13b41b0

Browse files
ebiedermLinus Torvalds
authored andcommitted
[PATCH] proc: Use struct pid not struct task_ref
Incrementally update my proc-dont-lock-task_structs-indefinitely patches so that they work with struct pid instead of struct task_ref. Mostly this is a straight 1-1 substitution. Signed-off-by: Eric W. Biederman <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 99f8955 commit 13b41b0

6 files changed

Lines changed: 18 additions & 20 deletions

File tree

‎fs/proc/base.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,7 @@ static ssize_t proc_loginuid_write(struct file * file, const char __user * buf,
951951
if (!capable(CAP_AUDIT_CONTROL))
952952
return -EPERM;
953953

954-
if (current != proc_tref(inode)->task)
954+
if (current != pid_task(proc_pid(inode), PIDTYPE_PID))
955955
return -EPERM;
956956

957957
if (count >= PAGE_SIZE)
@@ -1363,8 +1363,8 @@ static struct inode *proc_pid_make_inode(struct super_block * sb, struct task_st
13631363
/*
13641364
* grab the reference to task.
13651365
*/
1366-
ei->tref = tref_get_by_task(task);
1367-
if (!tref_task(ei->tref))
1366+
ei->pid = get_pid(task->pids[PIDTYPE_PID].pid);
1367+
if (!ei->pid)
13681368
goto out_unlock;
13691369

13701370
inode->i_uid = 0;
@@ -1482,7 +1482,7 @@ static int pid_delete_dentry(struct dentry * dentry)
14821482
* If so, then don't put the dentry on the lru list,
14831483
* kill it immediately.
14841484
*/
1485-
return !proc_tref(dentry->d_inode)->task;
1485+
return !proc_pid(dentry->d_inode)->tasks[PIDTYPE_PID].first;
14861486
}
14871487

14881488
static struct dentry_operations tid_fd_dentry_operations =

‎fs/proc/inode.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ static void proc_delete_inode(struct inode *inode)
6262
truncate_inode_pages(&inode->i_data, 0);
6363

6464
/* Stop tracking associated processes */
65-
tref_put(PROC_I(inode)->tref);
65+
put_pid(PROC_I(inode)->pid);
6666

6767
/* Let go of any associated proc directory entry */
6868
de = PROC_I(inode)->pde;
@@ -91,7 +91,7 @@ static struct inode *proc_alloc_inode(struct super_block *sb)
9191
ei = (struct proc_inode *)kmem_cache_alloc(proc_inode_cachep, SLAB_KERNEL);
9292
if (!ei)
9393
return NULL;
94-
ei->tref = NULL;
94+
ei->pid = NULL;
9595
ei->fd = 0;
9696
ei->op.proc_get_link = NULL;
9797
ei->pde = NULL;

‎fs/proc/internal.h‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
*/
1111

1212
#include <linux/proc_fs.h>
13-
#include <linux/task_ref.h>
1413

1514
struct vmalloc_info {
1615
unsigned long used;
@@ -51,14 +50,14 @@ void free_proc_entry(struct proc_dir_entry *de);
5150

5251
int proc_init_inodecache(void);
5352

54-
static inline struct task_ref *proc_tref(struct inode *inode)
53+
static inline struct pid *proc_pid(struct inode *inode)
5554
{
56-
return PROC_I(inode)->tref;
55+
return PROC_I(inode)->pid;
5756
}
5857

5958
static inline struct task_struct *get_proc_task(struct inode *inode)
6059
{
61-
return get_tref_task(proc_tref(inode));
60+
return get_pid_task(proc_pid(inode), PIDTYPE_PID);
6261
}
6362

6463
static inline int proc_fd(struct inode *inode)

‎fs/proc/task_mmu.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ static void *m_start(struct seq_file *m, loff_t *pos)
320320
if (last_addr == -1UL)
321321
return NULL;
322322

323-
priv->task = get_tref_task(priv->tref);
323+
priv->task = get_pid_task(priv->pid, PIDTYPE_PID);
324324
if (!priv->task)
325325
return NULL;
326326

@@ -416,7 +416,7 @@ static int do_maps_open(struct inode *inode, struct file *file,
416416
int ret = -ENOMEM;
417417
priv = kzalloc(sizeof(*priv), GFP_KERNEL);
418418
if (priv) {
419-
priv->tref = proc_tref(inode);
419+
priv->pid = proc_pid(inode);
420420
ret = seq_open(file, ops);
421421
if (!ret) {
422422
struct seq_file *m = file->private_data;

‎include/linux/proc_fs.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ extern void kclist_add(struct kcore_list *, void *, size_t);
246246
#endif
247247

248248
struct proc_inode {
249-
struct task_ref *tref;
249+
struct pid *pid;
250250
int fd;
251251
union {
252252
int (*proc_get_link)(struct inode *, struct dentry **, struct vfsmount **);
@@ -267,7 +267,7 @@ static inline struct proc_dir_entry *PDE(const struct inode *inode)
267267
}
268268

269269
struct proc_maps_private {
270-
struct task_ref *tref;
270+
struct pid *pid;
271271
struct task_struct *task;
272272
struct vm_area_struct *tail_vma;
273273
};

‎kernel/cpuset.c‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@
5050
#include <linux/time.h>
5151
#include <linux/backing-dev.h>
5252
#include <linux/sort.h>
53-
#include <linux/task_ref.h>
5453

5554
#include <asm/uaccess.h>
5655
#include <asm/atomic.h>
@@ -2443,7 +2442,7 @@ void __cpuset_memory_pressure_bump(void)
24432442
*/
24442443
static int proc_cpuset_show(struct seq_file *m, void *v)
24452444
{
2446-
struct task_ref *tref;
2445+
struct pid *pid;
24472446
struct task_struct *tsk;
24482447
char *buf;
24492448
int retval;
@@ -2454,8 +2453,8 @@ static int proc_cpuset_show(struct seq_file *m, void *v)
24542453
goto out;
24552454

24562455
retval = -ESRCH;
2457-
tref = m->private;
2458-
tsk = get_tref_task(tref);
2456+
pid = m->private;
2457+
tsk = get_pid_task(pid, PIDTYPE_PID);
24592458
if (!tsk)
24602459
goto out_free;
24612460

@@ -2478,8 +2477,8 @@ static int proc_cpuset_show(struct seq_file *m, void *v)
24782477

24792478
static int cpuset_open(struct inode *inode, struct file *file)
24802479
{
2481-
struct task_ref *tref = PROC_I(inode)->tref;
2482-
return single_open(file, proc_cpuset_show, tref);
2480+
struct pid *pid = PROC_I(inode)->pid;
2481+
return single_open(file, proc_cpuset_show, pid);
24832482
}
24842483

24852484
struct file_operations proc_cpuset_operations = {

0 commit comments

Comments
 (0)