Skip to content

Commit ba25f9d

Browse files
xemulLinus Torvalds
authored andcommitted
Use helpers to obtain task pid in printks
The task_struct->pid member is going to be deprecated, so start using the helpers (task_pid_nr/task_pid_vnr/task_pid_nr_ns) in the kernel. The first thing to start with is the pid, printed to dmesg - in this case we may safely use task_pid_nr(). Besides, printks produce more (much more) than a half of all the explicit pid usage. [akpm@linux-foundation.org: git-drm went and changed lots of stuff] Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Cc: Dave Airlie <airlied@linux.ie> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 9a2e705 commit ba25f9d

47 files changed

Lines changed: 97 additions & 90 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎block/ll_rw_blk.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3367,7 +3367,7 @@ void submit_bio(int rw, struct bio *bio)
33673367
if (unlikely(block_dump)) {
33683368
char b[BDEVNAME_SIZE];
33693369
printk(KERN_DEBUG "%s(%d): %s block %Lu on %s\n",
3370-
current->comm, current->pid,
3370+
current->comm, task_pid_nr(current),
33713371
(rw & WRITE) ? "WRITE" : "READ",
33723372
(unsigned long long)bio->bi_sector,
33733373
bdevname(bio->bi_bdev,b));

‎drivers/block/nbd.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
188188
if (signal_pending(current)) {
189189
siginfo_t info;
190190
printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n",
191-
current->pid, current->comm,
191+
task_pid_nr(current), current->comm,
192192
dequeue_signal_lock(current, &current->blocked, &info));
193193
result = -EINTR;
194194
sock_shutdown(lo, !send);

‎drivers/cdrom/cdrom.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1107,7 +1107,7 @@ int open_for_data(struct cdrom_device_info * cdi)
11071107
is the default case! */
11081108
cdinfo(CD_OPEN, "bummer. wrong media type.\n");
11091109
cdinfo(CD_WARNING, "pid %d must open device O_NONBLOCK!\n",
1110-
(unsigned int)current->pid);
1110+
(unsigned int)task_pid_nr(current));
11111111
ret=-EMEDIUMTYPE;
11121112
goto clean_up_and_return;
11131113
}

‎drivers/char/drm/drm_bufs.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1456,7 +1456,7 @@ int drm_freebufs(struct drm_device *dev, void *data,
14561456
buf = dma->buflist[idx];
14571457
if (buf->file_priv != file_priv) {
14581458
DRM_ERROR("Process %d freeing buffer not owned\n",
1459-
current->pid);
1459+
task_pid_nr(current));
14601460
return -EINVAL;
14611461
}
14621462
drm_free_buffer(dev, buf);

‎drivers/char/drm/drm_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ int drm_ioctl(struct inode *inode, struct file *filp,
463463
++file_priv->ioctl_count;
464464

465465
DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
466-
current->pid, cmd, nr,
466+
task_pid_nr(current), cmd, nr,
467467
(long)old_encode_dev(file_priv->head->device),
468468
file_priv->authenticated);
469469

‎drivers/char/drm/drm_fops.c‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
234234
if (!drm_cpu_valid())
235235
return -EINVAL;
236236

237-
DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);
237+
DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor);
238238

239239
priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
240240
if (!priv)
@@ -244,7 +244,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
244244
filp->private_data = priv;
245245
priv->filp = filp;
246246
priv->uid = current->euid;
247-
priv->pid = current->pid;
247+
priv->pid = task_pid_nr(current);
248248
priv->minor = minor;
249249
priv->head = drm_heads[minor];
250250
priv->ioctl_count = 0;
@@ -339,7 +339,8 @@ int drm_release(struct inode *inode, struct file *filp)
339339
*/
340340

341341
DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
342-
current->pid, (long)old_encode_dev(file_priv->head->device),
342+
task_pid_nr(current),
343+
(long)old_encode_dev(file_priv->head->device),
343344
dev->open_count);
344345

345346
if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {

‎drivers/char/drm/drm_lock.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,12 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
5858

5959
if (lock->context == DRM_KERNEL_CONTEXT) {
6060
DRM_ERROR("Process %d using kernel context %d\n",
61-
current->pid, lock->context);
61+
task_pid_nr(current), lock->context);
6262
return -EINVAL;
6363
}
6464

6565
DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
66-
lock->context, current->pid,
66+
lock->context, task_pid_nr(current),
6767
dev->lock.hw_lock->lock, lock->flags);
6868

6969
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
@@ -153,7 +153,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
153153

154154
if (lock->context == DRM_KERNEL_CONTEXT) {
155155
DRM_ERROR("Process %d using kernel context %d\n",
156-
current->pid, lock->context);
156+
task_pid_nr(current), lock->context);
157157
return -EINVAL;
158158
}
159159

‎drivers/char/drm/drm_os_linux.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
#include <linux/delay.h>
88

99
/** Current process ID */
10-
#define DRM_CURRENTPID current->pid
10+
#define DRM_CURRENTPID task_pid_nr(current)
1111
#define DRM_SUSER(p) capable(CAP_SYS_ADMIN)
1212
#define DRM_UDELAY(d) udelay(d)
1313
/** Read a byte from a MMIO region */

‎drivers/char/drm/i810_dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1024,7 +1024,7 @@ static int i810_getbuf(struct drm_device *dev, void *data,
10241024
retcode = i810_dma_get_buffer(dev, d, file_priv);
10251025

10261026
DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
1027-
current->pid, retcode, d->granted);
1027+
task_pid_nr(current), retcode, d->granted);
10281028

10291029
sarea_priv->last_dispatch = (int)hw_status[5];
10301030

‎drivers/char/drm/i830_dma.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ static int i830_getbuf(struct drm_device *dev, void *data,
14091409
retcode = i830_dma_get_buffer(dev, d, file_priv);
14101410

14111411
DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n",
1412-
current->pid, retcode, d->granted);
1412+
task_pid_nr(current), retcode, d->granted);
14131413

14141414
sarea_priv->last_dispatch = (int)hw_status[5];
14151415

0 commit comments

Comments
 (0)