* [PATCH] Rename struct task variables from p to tsk
@ 2011-01-12 15:19 Eric B Munson
2011-01-12 18:05 ` Christoph Lameter
` (3 more replies)
0 siblings, 4 replies; 7+ messages in thread
From: Eric B Munson @ 2011-01-12 15:19 UTC (permalink / raw)
To: akpm; +Cc: linux-mm, mel, linux-kernel, Eric B Munson
p is not a meaningful identifier, this patch replaces all instances
in page_alloc.c of p when used as a struct task with the more useful
tsk.
Signed-off-by: Eric B Munson <emunson@mgebm.net>
---
mm/page_alloc.c | 22 +++++++++++-----------
1 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index ff7e158..acfbb20 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -1852,23 +1852,23 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
{
struct page *page = NULL;
struct reclaim_state reclaim_state;
- struct task_struct *p = current;
+ struct task_struct *tsk = current;
bool drained = false;
cond_resched();
/* We now go into synchronous reclaim */
cpuset_memory_pressure_bump();
- p->flags |= PF_MEMALLOC;
+ tsk->flags |= PF_MEMALLOC;
lockdep_set_current_reclaim_state(gfp_mask);
reclaim_state.reclaimed_slab = 0;
- p->reclaim_state = &reclaim_state;
+ tsk->reclaim_state = &reclaim_state;
*did_some_progress = try_to_free_pages(zonelist, order, gfp_mask, nodemask);
- p->reclaim_state = NULL;
+ tsk->reclaim_state = NULL;
lockdep_clear_current_reclaim_state();
- p->flags &= ~PF_MEMALLOC;
+ tsk->flags &= ~PF_MEMALLOC;
cond_resched();
@@ -1932,7 +1932,7 @@ void wake_all_kswapd(unsigned int order, struct zonelist *zonelist,
static inline int
gfp_to_alloc_flags(gfp_t gfp_mask)
{
- struct task_struct *p = current;
+ struct task_struct *tsk = current;
int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET;
const gfp_t wait = gfp_mask & __GFP_WAIT;
@@ -1954,12 +1954,12 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
* See also cpuset_zone_allowed() comment in kernel/cpuset.c.
*/
alloc_flags &= ~ALLOC_CPUSET;
- } else if (unlikely(rt_task(p)) && !in_interrupt())
+ } else if (unlikely(rt_task(tsk)) && !in_interrupt())
alloc_flags |= ALLOC_HARDER;
if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) {
if (!in_interrupt() &&
- ((p->flags & PF_MEMALLOC) ||
+ ((tsk->flags & PF_MEMALLOC) ||
unlikely(test_thread_flag(TIF_MEMDIE))))
alloc_flags |= ALLOC_NO_WATERMARKS;
}
@@ -1978,7 +1978,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
int alloc_flags;
unsigned long pages_reclaimed = 0;
unsigned long did_some_progress;
- struct task_struct *p = current;
+ struct task_struct *tsk = current;
/*
* In the slowpath, we sanity check order to avoid ever trying to
@@ -2034,7 +2034,7 @@ rebalance:
goto nopage;
/* Avoid recursion of direct reclaim */
- if (p->flags & PF_MEMALLOC)
+ if (tsk->flags & PF_MEMALLOC)
goto nopage;
/* Avoid allocations with no watermarks from looping endlessly */
@@ -2108,7 +2108,7 @@ nopage:
if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) {
printk(KERN_WARNING "%s: page allocation failure."
" order:%d, mode:0x%x\n",
- p->comm, order, gfp_mask);
+ tsk->comm, order, gfp_mask);
dump_stack();
show_mem();
}
--
1.7.1
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] Rename struct task variables from p to tsk
2011-01-12 15:19 [PATCH] Rename struct task variables from p to tsk Eric B Munson
@ 2011-01-12 18:05 ` Christoph Lameter
2011-01-12 20:16 ` Eric B Munson
2011-01-12 20:16 ` David Rientjes
` (2 subsequent siblings)
3 siblings, 1 reply; 7+ messages in thread
From: Christoph Lameter @ 2011-01-12 18:05 UTC (permalink / raw)
To: Eric B Munson; +Cc: akpm, linux-mm, mel, linux-kernel
Use t instead of p? Its a local variable after all.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rename struct task variables from p to tsk
2011-01-12 18:05 ` Christoph Lameter
@ 2011-01-12 20:16 ` Eric B Munson
2011-01-12 20:23 ` Christoph Lameter
0 siblings, 1 reply; 7+ messages in thread
From: Eric B Munson @ 2011-01-12 20:16 UTC (permalink / raw)
To: Christoph Lameter; +Cc: akpm, linux-mm, mel, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 270 bytes --]
On Wed, 12 Jan 2011, Christoph Lameter wrote:
>
> Use t instead of p? Its a local variable after all.
>
>
I don't find t any more informative than p. As a newcomer to most of this code
informative variable names, even for local variables, is a huge help.
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rename struct task variables from p to tsk
2011-01-12 15:19 [PATCH] Rename struct task variables from p to tsk Eric B Munson
2011-01-12 18:05 ` Christoph Lameter
@ 2011-01-12 20:16 ` David Rientjes
2011-01-12 23:14 ` Minchan Kim
2011-01-13 3:23 ` Huang Shijie
3 siblings, 0 replies; 7+ messages in thread
From: David Rientjes @ 2011-01-12 20:16 UTC (permalink / raw)
To: Eric B Munson; +Cc: Andrew Morton, linux-mm, Mel Gorman, linux-kernel
On Wed, 12 Jan 2011, Eric B Munson wrote:
> p is not a meaningful identifier, this patch replaces all instances
> in page_alloc.c of p when used as a struct task with the more useful
> tsk.
>
mm-page_allocc-dont-cache-current-in-a-local.patch removes all of the
stack allocations changed in this patch, so it's not needed.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rename struct task variables from p to tsk
2011-01-12 20:16 ` Eric B Munson
@ 2011-01-12 20:23 ` Christoph Lameter
0 siblings, 0 replies; 7+ messages in thread
From: Christoph Lameter @ 2011-01-12 20:23 UTC (permalink / raw)
To: Eric B Munson; +Cc: akpm, linux-mm, mel, linux-kernel
On Wed, 12 Jan 2011, Eric B Munson wrote:
> On Wed, 12 Jan 2011, Christoph Lameter wrote:
> > Use t instead of p? Its a local variable after all.
>
> I don't find t any more informative than p. As a newcomer to most of this code
> informative variable names, even for local variables, is a huge help.
Local variables are short because they are defined close to the point of
use.
tsk is not that informative and the notion of a "task" can refer to
various. However, when I see
struct task_struct *t;
I know what it refers to.
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rename struct task variables from p to tsk
2011-01-12 15:19 [PATCH] Rename struct task variables from p to tsk Eric B Munson
2011-01-12 18:05 ` Christoph Lameter
2011-01-12 20:16 ` David Rientjes
@ 2011-01-12 23:14 ` Minchan Kim
2011-01-13 3:23 ` Huang Shijie
3 siblings, 0 replies; 7+ messages in thread
From: Minchan Kim @ 2011-01-12 23:14 UTC (permalink / raw)
To: Eric B Munson; +Cc: akpm, linux-mm, mel, linux-kernel
On Thu, Jan 13, 2011 at 12:19 AM, Eric B Munson <emunson@mgebm.net> wrote:
> p is not a meaningful identifier, this patch replaces all instances
> in page_alloc.c of p when used as a struct task with the more useful
> tsk.
>
Yesterday, Andrew raise an eyebrow about that.
His simple lookup found below.
--
On Tue, 11 Jan 2011 13:03:22 -0800 (PST)
Hugh Dickins <hughd@google.com> wrote:
> On Tue, 11 Jan 2011, Andrew Morton wrote:
< snip >
> > Oh, and since when did we use `p' to identify task_structs?
>
> Tsk, tsk: we've been using `p' for task_structs for years and years!
Only bad people do that. "p". Really?
z:/usr/src/linux-2.6.37> grep -r " \*p;" . | wc -l
2329
z:/usr/src/linux-2.6.37> grep -r "task_struct \*p" . | wc -l
824
bah.
--
How about cleaning up everything in this chance?
--
Kind regards,
Minchan Kim
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] Rename struct task variables from p to tsk
2011-01-12 15:19 [PATCH] Rename struct task variables from p to tsk Eric B Munson
` (2 preceding siblings ...)
2011-01-12 23:14 ` Minchan Kim
@ 2011-01-13 3:23 ` Huang Shijie
3 siblings, 0 replies; 7+ messages in thread
From: Huang Shijie @ 2011-01-13 3:23 UTC (permalink / raw)
To: Eric B Munson; +Cc: akpm, linux-mm, mel, linux-kernel
> p is not a meaningful identifier, this patch replaces all instances
> in page_alloc.c of p when used as a struct task with the more useful
> tsk.
>
I also think `p` is good enough. The `tsk` feels cold.
> Signed-off-by: Eric B Munson <emunson@mgebm.net>
> ---
> mm/page_alloc.c | 22 +++++++++++-----------
> 1 files changed, 11 insertions(+), 11 deletions(-)
>
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index ff7e158..acfbb20 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -1852,23 +1852,23 @@ __alloc_pages_direct_reclaim(gfp_t gfp_mask, unsigned int order,
> {
> struct page *page = NULL;
> struct reclaim_state reclaim_state;
> - struct task_struct *p = current;
> + struct task_struct *tsk = current;
> bool drained = false;
>
> cond_resched();
>
> /* We now go into synchronous reclaim */
> cpuset_memory_pressure_bump();
> - p->flags |= PF_MEMALLOC;
> + tsk->flags |= PF_MEMALLOC;
> lockdep_set_current_reclaim_state(gfp_mask);
> reclaim_state.reclaimed_slab = 0;
> - p->reclaim_state = &reclaim_state;
> + tsk->reclaim_state = &reclaim_state;
>
> *did_some_progress = try_to_free_pages(zonelist, order, gfp_mask, nodemask);
>
> - p->reclaim_state = NULL;
> + tsk->reclaim_state = NULL;
> lockdep_clear_current_reclaim_state();
> - p->flags &= ~PF_MEMALLOC;
> + tsk->flags &= ~PF_MEMALLOC;
>
> cond_resched();
>
> @@ -1932,7 +1932,7 @@ void wake_all_kswapd(unsigned int order, struct zonelist *zonelist,
> static inline int
> gfp_to_alloc_flags(gfp_t gfp_mask)
> {
> - struct task_struct *p = current;
> + struct task_struct *tsk = current;
> int alloc_flags = ALLOC_WMARK_MIN | ALLOC_CPUSET;
> const gfp_t wait = gfp_mask & __GFP_WAIT;
>
> @@ -1954,12 +1954,12 @@ gfp_to_alloc_flags(gfp_t gfp_mask)
> * See also cpuset_zone_allowed() comment in kernel/cpuset.c.
> */
> alloc_flags &= ~ALLOC_CPUSET;
> - } else if (unlikely(rt_task(p)) && !in_interrupt())
> + } else if (unlikely(rt_task(tsk)) && !in_interrupt())
> alloc_flags |= ALLOC_HARDER;
>
> if (likely(!(gfp_mask & __GFP_NOMEMALLOC))) {
> if (!in_interrupt() &&
> - ((p->flags & PF_MEMALLOC) ||
> + ((tsk->flags & PF_MEMALLOC) ||
> unlikely(test_thread_flag(TIF_MEMDIE))))
> alloc_flags |= ALLOC_NO_WATERMARKS;
> }
> @@ -1978,7 +1978,7 @@ __alloc_pages_slowpath(gfp_t gfp_mask, unsigned int order,
> int alloc_flags;
> unsigned long pages_reclaimed = 0;
> unsigned long did_some_progress;
> - struct task_struct *p = current;
> + struct task_struct *tsk = current;
>
> /*
> * In the slowpath, we sanity check order to avoid ever trying to
> @@ -2034,7 +2034,7 @@ rebalance:
> goto nopage;
>
> /* Avoid recursion of direct reclaim */
> - if (p->flags & PF_MEMALLOC)
> + if (tsk->flags & PF_MEMALLOC)
> goto nopage;
>
> /* Avoid allocations with no watermarks from looping endlessly */
> @@ -2108,7 +2108,7 @@ nopage:
> if (!(gfp_mask & __GFP_NOWARN) && printk_ratelimit()) {
> printk(KERN_WARNING "%s: page allocation failure."
> " order:%d, mode:0x%x\n",
> - p->comm, order, gfp_mask);
> + tsk->comm, order, gfp_mask);
> dump_stack();
> show_mem();
> }
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom policy in Canada: sign http://dissolvethecrtc.ca/
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2011-01-13 3:21 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-12 15:19 [PATCH] Rename struct task variables from p to tsk Eric B Munson
2011-01-12 18:05 ` Christoph Lameter
2011-01-12 20:16 ` Eric B Munson
2011-01-12 20:23 ` Christoph Lameter
2011-01-12 20:16 ` David Rientjes
2011-01-12 23:14 ` Minchan Kim
2011-01-13 3:23 ` Huang Shijie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).