Re: [PATCH 04/10] mm, page_alloc: Remove unnecessary taking of a seqlock when cpusets are disabled

From: Vlastimil Babka
Date: Tue Jul 28 2015 - 08:32:20 EST


On 07/20/2015 10:00 AM, Mel Gorman wrote:
From: Mel Gorman <mgorman@xxxxxxx>

There is a seqcounter that protects spurious allocation fails when a task
is changing the allowed nodes in a cpuset. There is no need to check the
seqcounter until a cpuset exists.

If cpusets become enabled betwen _begin and _retry, then it will retry due to comparing with 0, but not crash, so it's safe.

Signed-off-by: Mel Gorman <mgorman@xxxxxxxx>

Acked-by: Vlastimil Babka <vbabka@xxxxxxx>

---
include/linux/cpuset.h | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/include/linux/cpuset.h b/include/linux/cpuset.h
index 1b357997cac5..6eb27cb480b7 100644
--- a/include/linux/cpuset.h
+++ b/include/linux/cpuset.h
@@ -104,6 +104,9 @@ extern void cpuset_print_task_mems_allowed(struct task_struct *p);
*/
static inline unsigned int read_mems_allowed_begin(void)
{
+ if (!cpusets_enabled())
+ return 0;
+
return read_seqcount_begin(&current->mems_allowed_seq);
}

@@ -115,6 +118,9 @@ static inline unsigned int read_mems_allowed_begin(void)
*/
static inline bool read_mems_allowed_retry(unsigned int seq)
{
+ if (!cpusets_enabled())
+ return false;
+
return read_seqcount_retry(&current->mems_allowed_seq, seq);
}



--
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/