Received: by 10.223.185.116 with SMTP id b49csp4242461wrg; Mon, 26 Feb 2018 13:55:00 -0800 (PST) X-Google-Smtp-Source: AG47ELtuOK8OUP0CsilhSzSQ8ewWpLDrIorkLkoG1SIOhB5eu1QaZfemLBpyXknTUvxK6PeuWhYa X-Received: by 2002:a17:902:b690:: with SMTP id c16-v6mr3758498pls.264.1519682100547; Mon, 26 Feb 2018 13:55:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519682100; cv=none; d=google.com; s=arc-20160816; b=N9riupWKO0hObR7CJKXDahBTWkpPHT28sgHpZCJwy8n17XerRPoQQfLR8bCsaGxRxy BgvYIHap1Lf7YVkErRQqTXNJ6r/+liS5ysUS9i3KExAZtHdZayfsQHvO0SBNOQowX+DV oBoDdCOfKXxXs6T+uA7AAPmkqX2lsqL0y6ASQE2BDMCwNLw7JYgzaJaR9SeWX4Hoa3qd JUxcMhgtTJszqJVNtax1Ak+DlVi70wVi1MzCme6JyUd1lDP7zEqfyTGpURWibSXpZZNq WnVSxPPlx5Z/UA6I2q+CZYR6JVNtio4NJiki3VAY5Tw3i1aUsnS9lXTCbnmrbTLcXum1 ph9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date:dkim-signature :arc-authentication-results; bh=tAvkFBMJ064LWGjIE8UNaJOx1fZ25TmV0lnfOfNyugg=; b=OArgmAxIHBXaK4x+0KVNJvIIdIBSc8poVrjMcvNMWe0U3r903jdPcDBtwZ2qQU4Sni t7kXsci2OLI2gALeDma44kIlPqPqVQ/hzA/XAyu0wtYa2sieLBUzmciIscoIsUxuq1iu C8XOMWM6/fBQQ1WzcUHGvUGVmz6YS0vpvA97n415aJuT9fovmHNm3lnnvqcUYL5doFov r0prz8Jm2TDIPFGMNYP3M3Mt4IOysi5d37Bmm3CyLY73qPxHf98O2YkS+sfmzYt8h5Wz Mo/ftFYPEhCk7kcHOajR8RoHzRhPIsSozfpDFGle0eDvbYDUF1eBak2yAAWHxoL25GwB Q+ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ANguFfP2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w130si7364889pfd.280.2018.02.26.13.54.44; Mon, 26 Feb 2018 13:55:00 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ANguFfP2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752009AbeBZVxQ (ORCPT + 99 others); Mon, 26 Feb 2018 16:53:16 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:36336 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751514AbeBZVxN (ORCPT ); Mon, 26 Feb 2018 16:53:13 -0500 Received: by mail-it0-f68.google.com with SMTP id u5so12851707itc.1 for ; Mon, 26 Feb 2018 13:53:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=tAvkFBMJ064LWGjIE8UNaJOx1fZ25TmV0lnfOfNyugg=; b=ANguFfP2PjiFhJR3kUXETdy1cHGmPj5ImJRNYDNhrCKgEAFcGl8HwwvWyGNtcOeT/R XqkwtrHoVH+egnrjApa9i2ltaB3G0ng2/LBA/KoDfwkIu+ed37CdhHNEQ4cMfNX9Zndb 5/aV0C6tIOkvjTII1BEmEgAnAGl2wtWrGOQfmdM+bDj56A5nmOm2LXNZZuBBDOIihYeF NGaGeaGkG5GqUqMWxup6/GO0eecUU6cIi+YiAeVEfvANS/+gnKJdBuFt6zX9fvMrXRAj /XcMug8ct2LRv3DjOfA9/miZgQRL5uI78Wn78JiQCHuGDpxW6XUPNoLQTuNpwaG7g60o t2Gg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=tAvkFBMJ064LWGjIE8UNaJOx1fZ25TmV0lnfOfNyugg=; b=keT7s/W8tBPaAHTsDUkpXF1QutAYzw6L3zffk8+KtaZzrQMftC/zvaJSnY+Do4QaPV 93WVF4mSJL6Fqn2wgCyHaEZ53iTiL/kWNkCMafZb69V2ftCLIEYP6tMtKoT2acRrFNwG OkoRZ79kN7NEEdOIheuCjYo/oD5r7fsWHGJ5yE/Gh7O78BOcPqKopz4fkczw0oaznsbG b74AXbzaXh9Urk0/cfypvvQ4puvqQezvrE1y/DJeu/6naptdh+f1xx72pSnOHMETqOas PEB18KU6VfRz3LaCGzgkZTMvU4GR0/mm4RUs9UPwfHVRz2DcFt9W/ggVebSUcDfa+3hh IpwA== X-Gm-Message-State: APf1xPCeoK8XJ+9teviOhZ/fUMaAbalRArrAg3ZGaZrZdgAZAOeBD1Gv +f7OkGjVsSGlEXdZ0TNeD5+qpA== X-Received: by 10.36.74.202 with SMTP id k193mr3398850itb.150.1519681992613; Mon, 26 Feb 2018 13:53:12 -0800 (PST) Received: from [2620:15c:17:3:3a5:23a7:5e32:4598] ([2620:15c:17:3:3a5:23a7:5e32:4598]) by smtp.gmail.com with ESMTPSA id f5sm6061049iof.13.2018.02.26.13.53.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 26 Feb 2018 13:53:12 -0800 (PST) Date: Mon, 26 Feb 2018 13:53:10 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Aaron Lu cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Andrew Morton , Huang Ying , Dave Hansen , Kemi Wang , Tim Chen , Andi Kleen , Michal Hocko , Vlastimil Babka , Mel Gorman , Matthew Wilcox Subject: Re: [PATCH v3 2/3] mm/free_pcppages_bulk: do not hold lock when picking pages to free In-Reply-To: <20180226135346.7208-3-aaron.lu@intel.com> Message-ID: References: <20180226135346.7208-1-aaron.lu@intel.com> <20180226135346.7208-3-aaron.lu@intel.com> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 26 Feb 2018, Aaron Lu wrote: > diff --git a/mm/page_alloc.c b/mm/page_alloc.c > index 3154859cccd6..35576da0a6c9 100644 > --- a/mm/page_alloc.c > +++ b/mm/page_alloc.c > @@ -1116,13 +1116,11 @@ static void free_pcppages_bulk(struct zone *zone, int count, > int migratetype = 0; > int batch_free = 0; > bool isolated_pageblocks; > + struct page *page, *tmp; > + LIST_HEAD(head); > > pcp->count -= count; > - spin_lock(&zone->lock); > - isolated_pageblocks = has_isolate_pageblock(zone); > - > while (count) { > - struct page *page; > struct list_head *list; > > /* > @@ -1144,26 +1142,31 @@ static void free_pcppages_bulk(struct zone *zone, int count, > batch_free = count; > > do { > - int mt; /* migratetype of the to-be-freed page */ > - > page = list_last_entry(list, struct page, lru); > /* must delete as __free_one_page list manipulates */ Looks good in general, but I'm not sure how I reconcile this comment with the new implementation that later links page->lru again. > list_del(&page->lru); > > - mt = get_pcppage_migratetype(page); > - /* MIGRATE_ISOLATE page should not go to pcplists */ > - VM_BUG_ON_PAGE(is_migrate_isolate(mt), page); > - /* Pageblock could have been isolated meanwhile */ > - if (unlikely(isolated_pageblocks)) > - mt = get_pageblock_migratetype(page); > - > if (bulkfree_pcp_prepare(page)) > continue; > > - __free_one_page(page, page_to_pfn(page), zone, 0, mt); > - trace_mm_page_pcpu_drain(page, 0, mt); > + list_add_tail(&page->lru, &head); > } while (--count && --batch_free && !list_empty(list)); > } > + > + spin_lock(&zone->lock); > + isolated_pageblocks = has_isolate_pageblock(zone); > + > + list_for_each_entry_safe(page, tmp, &head, lru) { > + int mt = get_pcppage_migratetype(page); > + /* MIGRATE_ISOLATE page should not go to pcplists */ > + VM_BUG_ON_PAGE(is_migrate_isolate(mt), page); > + /* Pageblock could have been isolated meanwhile */ > + if (unlikely(isolated_pageblocks)) > + mt = get_pageblock_migratetype(page); > + > + __free_one_page(page, page_to_pfn(page), zone, 0, mt); > + trace_mm_page_pcpu_drain(page, 0, mt); > + } > spin_unlock(&zone->lock); > } >