Re: [PATCH 1/2] break out page allocation warning code

From: Dave Hansen
Date: Mon Apr 18 2011 - 17:03:26 EST


On Mon, 2011-04-18 at 13:25 -0700, David Rientjes wrote:
> - provide a statically-allocated buffer to use for get_task_comm() and
> copy current->comm over before printing it, or
>
> - take task_lock(current) to protect against /proc/pid/comm.
>
> The latter probably isn't safe because we could potentially already be
> holding task_lock(current) during a GFP_ATOMIC page allocation.

I'm not sure get_task_comm() is suitable, either. It takes the task
lock:

char *get_task_comm(char *buf, struct task_struct *tsk)
{
/* buf must be at least sizeof(tsk->comm) in size */
task_lock(tsk);
strncpy(buf, tsk->comm, sizeof(tsk->comm));
task_unlock(tsk);
return buf;
}

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/