From patchwork Sun Jan 1 18:52:16 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Nazarewicz X-Patchwork-Id: 9282 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1RhQWc-000890-12; Sun, 01 Jan 2012 19:52:54 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-2) with esmtp id 1RhQWa-0000bK-HZ; Sun, 01 Jan 2012 19:52:53 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751895Ab2AASwe (ORCPT + 4 others); Sun, 1 Jan 2012 13:52:34 -0500 Received: from mail-ee0-f46.google.com ([74.125.83.46]:38421 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751124Ab2AASwd convert rfc822-to-8bit (ORCPT ); Sun, 1 Jan 2012 13:52:33 -0500 Received: by eekc4 with SMTP id c4so14815397eek.19 for ; Sun, 01 Jan 2012 10:52:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=sender:content-type:to:cc:subject:references:date:mime-version :content-transfer-encoding:from:message-id:in-reply-to:user-agent; bh=kC+Q3RTOjqBBmo8SKJhrx5ZAcezNYEal9W5OBnu6hls=; b=hkViKjrm10XcJYbEbo9YmqFsgf6XVti7SrpOvxwVArEBzC1hI8rLpYiad9m2w6CB6x 4fdzRoa8SNNBO4P9zQEUIV2M9cWMek4Mm+whXXsnWmT0KlTZLbOlj5eVdG4/Ep6jmEF8 Ky+MiGf6gCDLg9sd88trxRQi7xfyhVC0DV1HA= Received: by 10.14.51.193 with SMTP id b41mr18261083eec.76.1325443952415; Sun, 01 Jan 2012 10:52:32 -0800 (PST) Received: from mpn-glaptop (77-253-110-28.adsl.inetia.pl. [77.253.110.28]) by mx.google.com with ESMTPS id 76sm180605736eeh.0.2012.01.01.10.52.24 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 01 Jan 2012 10:52:31 -0800 (PST) To: "Gilad Ben-Yossef" Cc: "Marek Szyprowski" , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-media@vger.kernel.org, linux-mm@kvack.org, linaro-mm-sig@lists.linaro.org, "Kyungmin Park" , "Russell King" , "Andrew Morton" , "KAMEZAWA Hiroyuki" , "Daniel Walker" , "Mel Gorman" , "Arnd Bergmann" , "Jesse Barker" , "Jonathan Corbet" , "Shariq Hasnain" , "Chunsang Jeong" , "Dave Hansen" , "Benjamin Gaignard" Subject: Re: [PATCH 01/11] mm: page_alloc: set_migratetype_isolate: drain PCP prior to isolating References: <1325162352-24709-1-git-send-email-m.szyprowski@samsung.com> <1325162352-24709-2-git-send-email-m.szyprowski@samsung.com> Date: Sun, 01 Jan 2012 19:52:16 +0100 MIME-Version: 1.0 From: "Michal Nazarewicz" Message-ID: In-Reply-To: User-Agent: Opera Mail/11.60 (Linux) Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.1.1.183916 X-PMX-Spam: Gauge=IIIIIIII, Probability=8%, Report=' MULTIPLE_RCPTS 0.1, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, ECARD_KNOWN_DOMAINS 0, INVALID_MSGID_NO_FQDN 0, __ANY_URI 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CP_URI_IN_BODY 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __HAS_MSGID 0, __HAS_X_MAILING_LIST 0, __HIGHBITS 0, __INT_PROD_COMP 0, __MIME_TEXT_ONLY 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __URI_NO_WWW 0, __URI_NS , __USER_AGENT 0' X-LSpam-Score: -1.9 (-) X-LSpam-Report: No, score=-1.9 required=5.0 tests=BAYES_00=-1.9, T_DKIM_INVALID=0.01 autolearn=ham On Sun, 01 Jan 2012 17:06:53 +0100, Gilad Ben-Yossef wrote: > 2012/1/1 Michal Nazarewicz : >> Looks interesting, I'm not entirely sure why it does not end up a race >> condition, but in case of __zone_drain_all_pages() we already hold > If a page is in the PCP list when we check, you'll send the IPI and all is well. > > If it isn't when we check and gets added later you could just the same have > situation where we send the IPI, try to do try an empty PCP list and then > the page gets added. So we are not adding a race condition that is not there > already :-) Right, makes sense. >> zone->lock, so my fears are somehow gone.. I'll give it a try, and prepare >> a patch for __zone_drain_all_pages(). > I plan to send V5 of the IPI noise patch after some testing. It has a new > version of the drain_all_pages, with no allocation in the reclaim path > and no locking. You might want to wait till that one is out to base on it. This shouldn't be a problem for my case as set_migratetype_isolate() is hardly ever called in reclaim path. :) The change so far seems rather obvious: mm/page_alloc.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 424d36a..eaa686b 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -1181,7 +1181,19 @@ static void __zone_drain_local_pages(void *arg) */ static void __zone_drain_all_pages(struct zone *zone) { - on_each_cpu(__zone_drain_local_pages, zone, 1); + struct per_cpu_pageset *pcp; + cpumask_var_t cpus; + int cpu; + + if (likely(zalloc_cpumask_var(&cpus, GFP_ATOMIC | __GFP_NOWARN))) { + for_each_online_cpu(cpu) + if (per_cpu_ptr(zone->pageset, cpu)->pcp.count) + cpumask_set_cpu(cpu, cpus); + on_each_cpu_mask(cpus, __zone_drain_local_pages, zone, 1); + free_cpumask_var(cpus); + } else { + on_each_cpu(__zone_drain_local_pages, zone, 1); + } } #ifdef CONFIG_HIBERNATION