Skip to content

Commit

Permalink
Use helpers to obtain task pid in printks
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
xemul authored and Linus Torvalds committed Oct 19, 2007
1 parent 9a2e705 commit ba25f9d
Show file tree
Hide file tree
Showing 47 changed files with 97 additions and 90 deletions.
2 changes: 1 addition & 1 deletion block/ll_rw_blk.c
Original file line number Diff line number Diff line change
Expand Up @@ -3367,7 +3367,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));
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/nbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ static int sock_xmit(struct nbd_device *lo, int send, void *buf, int size,
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, &current->blocked, &info));
result = -EINTR;
sock_shutdown(lo, !send);
Expand Down
2 changes: 1 addition & 1 deletion drivers/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -1107,7 +1107,7 @@ int open_for_data(struct cdrom_device_info * cdi)
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;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_bufs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1456,7 +1456,7 @@ int drm_freebufs(struct drm_device *dev, void *data,
buf = dma->buflist[idx];
if (buf->file_priv != file_priv) {
DRM_ERROR("Process %d freeing buffer not owned\n",
current->pid);
task_pid_nr(current));
return -EINVAL;
}
drm_free_buffer(dev, buf);
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ int drm_ioctl(struct inode *inode, struct file *filp,
++file_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(file_priv->head->device),
file_priv->authenticated);

Expand Down
7 changes: 4 additions & 3 deletions drivers/char/drm/drm_fops.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
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)
Expand All @@ -244,7 +244,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
filp->private_data = priv;
priv->filp = filp;
priv->uid = current->euid;
priv->pid = current->pid;
priv->pid = task_pid_nr(current);
priv->minor = minor;
priv->head = drm_heads[minor];
priv->ioctl_count = 0;
Expand Down Expand Up @@ -339,7 +339,8 @@ int drm_release(struct inode *inode, struct file *filp)
*/

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

if (dev->driver->reclaim_buffers_locked && dev->lock.hw_lock) {
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/drm/drm_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,12 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)

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))
Expand Down Expand Up @@ -153,7 +153,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)

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;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/drm_os_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include <linux/delay.h>

/** 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 */
Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/i810_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,7 +1024,7 @@ static int i810_getbuf(struct drm_device *dev, void *data,
retcode = i810_dma_get_buffer(dev, d, file_priv);

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

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

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/drm/i830_dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ static int i830_getbuf(struct drm_device *dev, void *data,
retcode = i830_dma_get_buffer(dev, d, file_priv);

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

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

Expand Down
2 changes: 1 addition & 1 deletion drivers/char/sx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1467,7 +1467,7 @@ static int sx_open(struct tty_struct *tty, struct file *filp)

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))
Expand Down
6 changes: 3 additions & 3 deletions drivers/char/tty_io.c
Original file line number Diff line number Diff line change
Expand Up @@ -3530,7 +3530,7 @@ void __do_SAK(struct tty_struct *tty)
do_each_pid_task(session, PIDTYPE_SID, p) {
printk(KERN_NOTICE "SAK: killed process %d"
" (%s): task_session_nr(p)==tty->session\n",
p->pid, p->comm);
task_pid_nr(p), p->comm);
send_sig(SIGKILL, p, 1);
} while_each_pid_task(session, PIDTYPE_SID, p);
/* Now kill any processes that happen to have the
Expand All @@ -3540,7 +3540,7 @@ void __do_SAK(struct tty_struct *tty)
if (p->signal->tty == tty) {
printk(KERN_NOTICE "SAK: killed process %d"
" (%s): task_session_nr(p)==tty->session\n",
p->pid, p->comm);
task_pid_nr(p), p->comm);
send_sig(SIGKILL, p, 1);
continue;
}
Expand All @@ -3560,7 +3560,7 @@ void __do_SAK(struct tty_struct *tty)
filp->private_data == tty) {
printk(KERN_NOTICE "SAK: killed process %d"
" (%s): fd#%d opened to the tty\n",
p->pid, p->comm, i);
task_pid_nr(p), p->comm, i);
force_sig(SIGKILL, p);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions drivers/hid/hidraw.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ static ssize_t hidraw_write(struct file *file, const char __user *buffer, size_t

if (count > HID_MIN_BUFFER_SIZE) {
printk(KERN_WARNING "hidraw: pid %d passed too large report\n",
current->pid);
task_pid_nr(current));
return -EINVAL;
}

if (count < 2) {
printk(KERN_WARNING "hidraw: pid %d passed too short report\n",
current->pid);
task_pid_nr(current));
return -EINVAL;
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -4717,7 +4717,7 @@ mdk_thread_t *md_register_thread(void (*run) (mddev_t *), mddev_t *mddev,

void md_unregister_thread(mdk_thread_t *thread)
{
dprintk("interrupting MD-thread pid %d\n", thread->tsk->pid);
dprintk("interrupting MD-thread pid %d\n", task_pid_nr(thread->tsk));

kthread_stop(thread->tsk);
kfree(thread);
Expand Down
4 changes: 2 additions & 2 deletions drivers/media/video/zoran_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ zoran_open (struct inode *inode,
}

dprintk(1, KERN_INFO "%s: zoran_open(%s, pid=[%d]), users(-)=%d\n",
ZR_DEVNAME(zr), current->comm, current->pid, zr->user);
ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user);

/* now, create the open()-specific file_ops struct */
fh = kzalloc(sizeof(struct zoran_fh), GFP_KERNEL);
Expand Down Expand Up @@ -1358,7 +1358,7 @@ zoran_close (struct inode *inode,
struct zoran *zr = fh->zr;

dprintk(1, KERN_INFO "%s: zoran_close(%s, pid=[%d]), users(+)=%d\n",
ZR_DEVNAME(zr), current->comm, current->pid, zr->user);
ZR_DEVNAME(zr), current->comm, task_pid_nr(current), zr->user);

/* kernel locks (fs/device.c), so don't do that ourselves
* (prevents deadlocks) */
Expand Down
2 changes: 1 addition & 1 deletion drivers/mtd/ubi/wl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ static int ubi_thread(void *u)
struct ubi_device *ubi = u;

ubi_msg("background thread \"%s\" started, PID %d",
ubi->bgt_name, current->pid);
ubi->bgt_name, task_pid_nr(current));

set_freezable();
for (;;) {
Expand Down
2 changes: 1 addition & 1 deletion drivers/net/wireless/hostap/hostap_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -2920,7 +2920,7 @@ static int prism2_ioctl_priv_monitor(struct net_device *dev, int *i)

printk(KERN_DEBUG "%s: process %d (%s) used deprecated iwpriv monitor "
"- update software to use iwconfig mode monitor\n",
dev->name, current->pid, current->comm);
dev->name, task_pid_nr(current), current->comm);

/* Backward compatibility code - this can be removed at some point */

Expand Down
8 changes: 4 additions & 4 deletions drivers/scsi/libsas/sas_discover.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static void sas_discover_domain(struct work_struct *work)
dev = port->port_dev;

SAS_DPRINTK("DOING DISCOVERY on port %d, pid:%d\n", port->id,
current->pid);
task_pid_nr(current));

switch (dev->dev_type) {
case SAS_END_DEV:
Expand Down Expand Up @@ -320,7 +320,7 @@ static void sas_discover_domain(struct work_struct *work)
}

SAS_DPRINTK("DONE DISCOVERY on port %d, pid:%d, result:%d\n", port->id,
current->pid, error);
task_pid_nr(current), error);
}

static void sas_revalidate_domain(struct work_struct *work)
Expand All @@ -334,12 +334,12 @@ static void sas_revalidate_domain(struct work_struct *work)
&port->disc.pending);

SAS_DPRINTK("REVALIDATING DOMAIN on port %d, pid:%d\n", port->id,
current->pid);
task_pid_nr(current));
if (port->port_dev)
res = sas_ex_revalidate_domain(port->port_dev);

SAS_DPRINTK("done REVALIDATING DOMAIN on port %d, pid:%d, res 0x%x\n",
port->id, current->pid, res);
port->id, task_pid_nr(current), res);
}

/* ---------- Events ---------- */
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/core/devio.c
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ static int checkintf(struct dev_state *ps, unsigned int ifnum)
return 0;
/* if not yet claimed, claim it for the driver */
dev_warn(&ps->dev->dev, "usbfs: process %d (%s) did not claim interface %u before use\n",
current->pid, current->comm, ifnum);
task_pid_nr(current), current->comm, ifnum);
return claimintf(ps, ifnum);
}

Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/gadget/file_storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -4006,7 +4006,7 @@ static int __init fsg_bind(struct usb_gadget *gadget)
DBG(fsg, "removable=%d, stall=%d, buflen=%u\n",
mod_data.removable, mod_data.can_stall,
mod_data.buflen);
DBG(fsg, "I/O thread pid: %d\n", fsg->thread_task->pid);
DBG(fsg, "I/O thread pid: %d\n", task_pid_nr(fsg->thread_task));

set_bit(REGISTERED, &fsg->atomic_bitflags);

Expand Down
2 changes: 1 addition & 1 deletion fs/cifs/connect.c
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server)

current->flags |= PF_MEMALLOC;
server->tsk = current; /* save process info to wake at shutdown */
cFYI(1, ("Demultiplex PID: %d", current->pid));
cFYI(1, ("Demultiplex PID: %d", task_pid_nr(current)));
write_lock(&GlobalSMBSeslock);
atomic_inc(&tcpSesAllocCount);
length = tcpSesAllocCount.counter;
Expand Down
2 changes: 1 addition & 1 deletion fs/dlm/user.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ static int check_version(struct dlm_write_request *req)
printk(KERN_DEBUG "dlm: process %s (%d) version mismatch "
"user (%d.%d.%d) kernel (%d.%d.%d)\n",
current->comm,
current->pid,
task_pid_nr(current),
req->version[0],
req->version[1],
req->version[2],
Expand Down
2 changes: 1 addition & 1 deletion fs/fs-writeback.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ void __mark_inode_dirty(struct inode *inode, int flags)
if (inode->i_ino || strcmp(inode->i_sb->s_id, "bdev"))
printk(KERN_DEBUG
"%s(%d): dirtied inode %lu (%s) on %s\n",
current->comm, current->pid, inode->i_ino,
current->comm, task_pid_nr(current), inode->i_ino,
name, inode->i_sb->s_id);
}

Expand Down
8 changes: 4 additions & 4 deletions fs/jffs2/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,28 @@
#define JFFS2_ERROR(fmt, ...) \
do { \
printk(JFFS2_ERR_MSG_PREFIX \
" (%d) %s: " fmt, current->pid, \
" (%d) %s: " fmt, task_pid_nr(current), \
__FUNCTION__ , ##__VA_ARGS__); \
} while(0)

#define JFFS2_WARNING(fmt, ...) \
do { \
printk(JFFS2_WARN_MSG_PREFIX \
" (%d) %s: " fmt, current->pid, \
" (%d) %s: " fmt, task_pid_nr(current), \
__FUNCTION__ , ##__VA_ARGS__); \
} while(0)

#define JFFS2_NOTICE(fmt, ...) \
do { \
printk(JFFS2_NOTICE_MSG_PREFIX \
" (%d) %s: " fmt, current->pid, \
" (%d) %s: " fmt, task_pid_nr(current), \
__FUNCTION__ , ##__VA_ARGS__); \
} while(0)

#define JFFS2_DEBUG(fmt, ...) \
do { \
printk(JFFS2_DBG_MSG_PREFIX \
" (%d) %s: " fmt, current->pid, \
" (%d) %s: " fmt, task_pid_nr(current), \
__FUNCTION__ , ##__VA_ARGS__); \
} while(0)

Expand Down
6 changes: 3 additions & 3 deletions fs/nfsd/vfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1029,13 +1029,13 @@ nfsd_vfs_write(struct svc_rqst *rqstp, struct svc_fh *fhp, struct file *file,
if (EX_WGATHER(exp)) {
if (atomic_read(&inode->i_writecount) > 1
|| (last_ino == inode->i_ino && last_dev == inode->i_sb->s_dev)) {
dprintk("nfsd: write defer %d\n", current->pid);
dprintk("nfsd: write defer %d\n", task_pid_nr(current));
msleep(10);
dprintk("nfsd: write resume %d\n", current->pid);
dprintk("nfsd: write resume %d\n", task_pid_nr(current));
}

if (inode->i_state & I_DIRTY) {
dprintk("nfsd: write sync %d\n", current->pid);
dprintk("nfsd: write sync %d\n", task_pid_nr(current));
host_err=nfsd_sync(file);
}
#if 0
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/cluster/heartbeat.c
Original file line number Diff line number Diff line change
Expand Up @@ -1372,7 +1372,7 @@ static ssize_t o2hb_region_pid_read(struct o2hb_region *reg,

spin_lock(&o2hb_live_lock);
if (reg->hr_task)
pid = reg->hr_task->pid;
pid = task_pid_nr(reg->hr_task);
spin_unlock(&o2hb_live_lock);

if (!pid)
Expand Down
2 changes: 1 addition & 1 deletion fs/ocfs2/cluster/masklog.h
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits;
* previous token if args expands to nothing.
*/
#define __mlog_printk(level, fmt, args...) \
printk(level "(%u,%lu):%s:%d " fmt, current->pid, \
printk(level "(%u,%lu):%s:%d " fmt, task_pid_nr(current), \
__mlog_cpu_guess, __PRETTY_FUNCTION__, __LINE__ , \
##args)

Expand Down
Loading

0 comments on commit ba25f9d

Please sign in to comment.