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.
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
---
Andrew, this patch changes many code in drivers and file systems,
so it may cause many conflicts with other fixes in -mm tree. Is
there any way I can help with it, e.g. split it into pieces, wait
till another -mm tree or something else?
block/ll_rw_blk.c | 2 +-
drivers/block/nbd.c | 2 +-
drivers/cdrom/cdrom.c | 2 +-
drivers/char/drm/drm_bufs.c | 2 +-
drivers/char/drm/drm_drv.c | 2 +-
drivers/char/drm/drm_fops.c | 4 ++--
drivers/char/drm/drm_lock.c | 6 +++---
drivers/char/drm/drm_os_linux.h | 2 +-
drivers/char/drm/i810_dma.c | 2 +-
drivers/char/drm/i830_dma.c | 2 +-
drivers/char/sx.c | 2 +-
drivers/char/tty_io.c | 6 +++---
drivers/hid/hidraw.c | 4 ++--
drivers/md/md.c | 2 +-
drivers/media/video/zoran_driver.c | 4 ++--
drivers/mtd/ubi/wl.c | 2 +-
drivers/net/wireless/hostap/hostap_ioctl.c | 2 +-
drivers/scsi/libsas/sas_discover.c | 8 ++++----
drivers/usb/core/devio.c | 2 +-
drivers/usb/gadget/file_storage.c | 2 +-
fs/cifs/connect.c | 2 +-
fs/dlm/user.c | 2 +-
fs/fs-writeback.c | 2 +-
fs/jffs2/debug.h | 8 ++++----
fs/nfsd/vfs.c | 6 +++---
fs/ocfs2/cluster/heartbeat.c | 2 +-
fs/ocfs2/cluster/masklog.h | 2 +-
fs/ocfs2/dlm/dlmrecovery.c | 10 +++++-----
fs/reiser4/debug.h | 2 +-
include/linux/reiserfs_fs.h | 2 +-
include/net/9p/9p.h | 4 ++--
kernel/cpu.c | 3 ++-
kernel/exit.c | 2 +-
kernel/lockdep.c | 22 +++++++++++-----------
kernel/rtmutex-debug.c | 15 +++++++++------
kernel/rtmutex.c | 2 +-
kernel/sched.c | 7 ++++---
kernel/signal.c | 2 +-
kernel/softlockup.c | 2 +-
kernel/workqueue.c | 2 +-
lib/spinlock_debug.c | 8 ++++----
mm/oom_kill.c | 5 +++--
net/core/pktgen.c | 2 +-
net/core/sock.c | 2 +-
net/ipv4/ipvs/ip_vs_sync.c | 4 ++--
net/ipv4/tcp.c | 2 +-
net/llc/af_llc.c | 2 +-
net/sunrpc/sched.c | 2 +-
48 files changed, 96 insertions(+), 90 deletions(-)
diff --git a/block/ll_rw_blk.c b/block/ll_rw_blk.c
index 2849ef4..f830872 100644
--- a/block/ll_rw_blk.c
+++ b/block/ll_rw_blk.c
@@ -3303,7 +3303,7 @@ void submit_bio(int rw, struct bio *bio)
if (unlikely(block_dump)) {
char b[BDEVNAME_SIZE];
printk(KERN_DEBUG "%s(%d): %s block %Lu on %s\n",
- current->comm, current->pid,
+ current->comm, task_pid_nr(current),
(rw & WRITE) ? "WRITE" : "READ",
(unsigned long long)bio->bi_sector,
bdevname(bio->bi_bdev,b));
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 84d139b..a539eca 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -147,7 +147,7 @@ static int sock_xmit(struct socket *sock
if (signal_pending(current)) {
siginfo_t info;
printk(KERN_WARNING "nbd (pid %d: %s) got signal %d\n",
- current->pid, current->comm,
+ task_pid_nr(current), current->comm,
dequeue_signal_lock(current, ¤t->blocked, &info));
result = -EINTR;
break;
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c
index f0c6318..e5f2339 100644
--- a/drivers/cdrom/cdrom.c
+++ b/drivers/cdrom/cdrom.c
@@ -1103,7 +1103,7 @@ int open_for_data(struct cdrom_device_in
is the default case! */
cdinfo(CD_OPEN, "bummer. wrong media type.\n");
cdinfo(CD_WARNING, "pid %d must open device O_NONBLOCK!\n",
- (unsigned int)current->pid);
+ (unsigned int)task_pid_nr(current));
ret=-EMEDIUMTYPE;
goto clean_up_and_return;
}
diff --git a/drivers/char/drm/drm_bufs.c b/drivers/char/drm/drm_bufs.c
index 3d1ec82..eb67480 100644
--- a/drivers/char/drm/drm_bufs.c
+++ b/drivers/char/drm/drm_bufs.c
@@ -1502,7 +1502,7 @@ int drm_freebufs(struct inode *inode, st
buf = dma->buflist[idx];
if (buf->filp != filp) {
DRM_ERROR("Process %d freeing buffer not owned\n",
- current->pid);
+ task_pid_nr(current));
return -EINVAL;
}
drm_free_buffer(dev, buf);
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c
index 19994cd..30f714c 100644
--- a/drivers/char/drm/drm_drv.c
+++ b/drivers/char/drm/drm_drv.c
@@ -469,7 +469,7 @@ int drm_ioctl(struct inode *inode, struc
++priv->ioctl_count;
DRM_DEBUG("pid=%d, cmd=0x%02x, nr=0x%02x, dev 0x%lx, auth=%d\n",
- current->pid, cmd, nr,
+ task_pid_nr(current), cmd, nr,
(long)old_encode_dev(priv->head->device),
priv->authenticated);
diff --git a/drivers/char/drm/drm_fops.c b/drivers/char/drm/drm_fops.c
index 7bc51ba..faaf219 100644
--- a/drivers/char/drm/drm_fops.c
+++ b/drivers/char/drm/drm_fops.c
@@ -234,7 +234,7 @@ static int drm_open_helper(struct inode
if (!drm_cpu_valid())
return -EINVAL;
- DRM_DEBUG("pid = %d, minor = %d\n", current->pid, minor);
+ DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor);
priv = drm_alloc(sizeof(*priv), DRM_MEM_FILES);
if (!priv)
@@ -339,7 +339,7 @@ int drm_release(struct inode *inode, str
*/
DRM_DEBUG("pid = %d, device = 0x%lx, open_count = %d\n",
- current->pid, (long)old_encode_dev(priv->head->device),
+ task_pid_nr(current), (long)old_encode_dev(priv->head->device),
dev->open_count);
if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index c0534b5..7f85a0a 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -64,12 +64,12 @@ int drm_lock(struct inode *inode, struct
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
- current->pid, lock.context);
+ task_pid_nr(current), lock.context);
return -EINVAL;
}
DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
- lock.context, current->pid,
+ lock.context, task_pid_nr(current),
dev->lock.hw_lock->lock, lock.flags);
if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
@@ -162,7 +162,7 @@ int drm_unlock(struct inode *inode, stru
if (lock.context == DRM_KERNEL_CONTEXT) {
DRM_ERROR("Process %d using kernel context %d\n",
- current->pid, lock.context);
+ task_pid_nr(current), lock.context);
return -EINVAL;
}
diff --git a/drivers/char/drm/drm_os_linux.h b/drivers/char/drm/drm_os_linux.h
index 0b8d343..6bb8929 100644
--- a/drivers/char/drm/drm_os_linux.h
+++ b/drivers/char/drm/drm_os_linux.h
@@ -12,7 +12,7 @@
#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
#define DRM_ERR(d) -(d)
/** Current process ID */
-#define DRM_CURRENTPID current->pid
+#define DRM_CURRENTPID task_pid_nr(current)
#define DRM_SUSER(p) capable(CAP_SYS_ADMIN)
#define DRM_UDELAY(d) udelay(d)
/** Read a byte from a MMIO region */
diff --git a/drivers/char/drm/i810_dma.c b/drivers/char/drm/i810_dma.c
index cb44999..8cd5433 100644
--- a/drivers/char/drm/i810_dma.c
+++ b/drivers/char/drm/i810_dma.c
@@ -1119,7 +1119,7 @@ static int i810_getbuf(struct inode *ino
retcode = i810_dma_get_buffer(dev, &d, filp);
DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n",
- current->pid, retcode, d.granted);
+ task_pid_nr(current), retcode, d.granted);
if (copy_to_user((void __user *) arg, &d, sizeof(d)))
return -EFAULT;
diff --git a/drivers/char/drm/i830_dma.c b/drivers/char/drm/i830_dma.c
index dc20c1a..e94077f 100644
--- a/drivers/char/drm/i830_dma.c
+++ b/drivers/char/drm/i830_dma.c
@@ -1441,7 +1441,7 @@ static int i830_getbuf(struct inode *ino
retcode = i830_dma_get_buffer(dev, &d, filp);
DRM_DEBUG("i830_dma: %d returning %d, granted = %d\n",
- current->pid, retcode, d.granted);
+ task_pid_nr(current), retcode, d.granted);
if (copy_to_user((void __user *) arg, &d, sizeof(d)))
return -EFAULT;
diff --git a/drivers/char/sx.c b/drivers/char/sx.c
index 85a2328..a6e1c9b 100644
--- a/drivers/char/sx.c
+++ b/drivers/char/sx.c
@@ -1467,7 +1467,7 @@ static int sx_open(struct tty_struct *tt
line = tty->index;
sx_dprintk(SX_DEBUG_OPEN, "%d: opening line %d. tty=%p ctty=%p, "
- "np=%d)\n", current->pid, line, tty,
+ "np=%d)\n", task_pid_nr(current), line, tty,
current->signal->tty, sx_nports);
if ((line < 0) || (line >= SX_NPORTS) || (line >= sx_nports))
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 583a2d9..e9da99c 1006
...