From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jiang Liu Subject: Re: [PATCH v4, part3 11/15] mm: use a dedicated lock to protect totalram_pages and zone->managed_pages Date: Tue, 09 Apr 2013 00:05:54 +0800 Message-ID: <5162EAE2.6010306@gmail.com> References: <1365256509-29024-1-git-send-email-jiang.liu@huawei.com> <1365256509-29024-12-git-send-email-jiang.liu@huawei.com> <5162C887.5070900@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5162C887.5070900@redhat.com> Sender: linux-kernel-owner@vger.kernel.org To: Rik van Riel Cc: Andrew Morton , Jiang Liu , David Rientjes , Wen Congyang , Mel Gorman , Minchan Kim , KAMEZAWA Hiroyuki , Michal Hocko , James Bottomley , Sergei Shtylyov , David Howells , Mark Salter , Jianguo Wu , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Michel Lespinasse List-Id: linux-arch.vger.kernel.org On 04/08/2013 09:39 PM, Rik van Riel wrote: > On 04/06/2013 09:55 AM, Jiang Liu wrote: > >> @@ -5186,6 +5189,22 @@ early_param("movablecore", cmdline_parse_movablecore); >> >> #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ >> >> +void adjust_managed_page_count(struct page *page, long count) >> +{ >> + bool lock = (system_state != SYSTEM_BOOTING); >> + >> + /* No need to acquire the lock during boot */ >> + if (lock) >> + spin_lock(&managed_page_count_lock); >> + >> + page_zone(page)->managed_pages += count; >> + totalram_pages += count; >> + >> + if (lock) >> + spin_unlock(&managed_page_count_lock); >> +} > > While I agree the boot code currently does not need the lock, is > there any harm to removing that conditional? > > That would simplify the code, and protect against possible future > cleverness of initializing multiple memory things simultaneously. > Hi Rik, Thanks for you comments. I'm OK with that. Acquiring/releasing the lock should be lightweight because there shouldn't be contention during boot. Will remove the logic in next version. Regards! Gerry From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-oa0-f50.google.com ([209.85.219.50]:36919 "EHLO mail-oa0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1760508Ab3DHQGH (ORCPT ); Mon, 8 Apr 2013 12:06:07 -0400 Message-ID: <5162EAE2.6010306@gmail.com> Date: Tue, 09 Apr 2013 00:05:54 +0800 From: Jiang Liu MIME-Version: 1.0 Subject: Re: [PATCH v4, part3 11/15] mm: use a dedicated lock to protect totalram_pages and zone->managed_pages References: <1365256509-29024-1-git-send-email-jiang.liu@huawei.com> <1365256509-29024-12-git-send-email-jiang.liu@huawei.com> <5162C887.5070900@redhat.com> In-Reply-To: <5162C887.5070900@redhat.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Sender: linux-arch-owner@vger.kernel.org List-ID: To: Rik van Riel Cc: Andrew Morton , Jiang Liu , David Rientjes , Wen Congyang , Mel Gorman , Minchan Kim , KAMEZAWA Hiroyuki , Michal Hocko , James Bottomley , Sergei Shtylyov , David Howells , Mark Salter , Jianguo Wu , linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, Michel Lespinasse Message-ID: <20130408160554.MI5EAXuDXfMfyMOL7IKdOUR52xr8FM-xUslZ6gZtLaY@z> On 04/08/2013 09:39 PM, Rik van Riel wrote: > On 04/06/2013 09:55 AM, Jiang Liu wrote: > >> @@ -5186,6 +5189,22 @@ early_param("movablecore", cmdline_parse_movablecore); >> >> #endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */ >> >> +void adjust_managed_page_count(struct page *page, long count) >> +{ >> + bool lock = (system_state != SYSTEM_BOOTING); >> + >> + /* No need to acquire the lock during boot */ >> + if (lock) >> + spin_lock(&managed_page_count_lock); >> + >> + page_zone(page)->managed_pages += count; >> + totalram_pages += count; >> + >> + if (lock) >> + spin_unlock(&managed_page_count_lock); >> +} > > While I agree the boot code currently does not need the lock, is > there any harm to removing that conditional? > > That would simplify the code, and protect against possible future > cleverness of initializing multiple memory things simultaneously. > Hi Rik, Thanks for you comments. I'm OK with that. Acquiring/releasing the lock should be lightweight because there shouldn't be contention during boot. Will remove the logic in next version. Regards! Gerry