Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932574AbbGTOzn (ORCPT ); Mon, 20 Jul 2015 10:55:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48591 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756328AbbGTOzk (ORCPT ); Mon, 20 Jul 2015 10:55:40 -0400 From: Baoquan He To: tj@kernel.org, cl@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Baoquan He Subject: [PATCH 2/3] perpuc: check pcpu_first_chunk and pcpu_reserved_chunk to avoid handling them twice Date: Mon, 20 Jul 2015 22:55:29 +0800 Message-Id: <1437404130-5188-2-git-send-email-bhe@redhat.com> In-Reply-To: <1437404130-5188-1-git-send-email-bhe@redhat.com> References: <1437404130-5188-1-git-send-email-bhe@redhat.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1601 Lines: 47 In pcpu_setup_first_chunk() pcpu_reserved_chunk is assigned to point to static chunk. While pcpu_first_chunk is got from below code: pcpu_first_chunk = dchunk ?: schunk; Then it could point to static chunk too if dynamic chunk doesn't exist. So in this patch adding a check in percpu_init_late() to see if pcpu_first_chunk is equal to pcpu_reserved_chunk. Only if they are not equal we add pcpu_reserved_chunk to the target array. Signed-off-by: Baoquan He --- mm/percpu.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/mm/percpu.c b/mm/percpu.c index a63b4d8..f7e02c0 100644 --- a/mm/percpu.c +++ b/mm/percpu.c @@ -2260,11 +2260,18 @@ void __init setup_per_cpu_areas(void) void __init percpu_init_late(void) { struct pcpu_chunk *target_chunks[] = - { pcpu_first_chunk, pcpu_reserved_chunk, NULL }; + { pcpu_first_chunk, NULL, NULL }; struct pcpu_chunk *chunk; unsigned long flags; int i; + /* + * pcpu_first_chunk could be the same as pcpu_reserved_chunk, add it to the + * target array only if pcpu_first_chunk is not equal to pcpu_reserved_chunk. + */ + if (pcpu_first_chunk != pcpu_reserved_chunk) + target_chunks[1] = pcpu_reserved_chunk; + for (i = 0; (chunk = target_chunks[i]); i++) { int *map; const size_t size = PERCPU_DYNAMIC_EARLY_SLOTS * sizeof(map[0]); -- 1.9.3 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/