Received: by 2002:a05:6a10:413:0:0:0:0 with SMTP id 19csp1963899pxp; Thu, 10 Mar 2022 16:12:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0hQgUa4fp/0sdO7TQ9gXHJDjFnKTovzsqOds8hOOC1w5eXvZ3x6Dundrrv3GGTom/Mgsz X-Received: by 2002:a63:802:0:b0:374:2e45:c6fa with SMTP id 2-20020a630802000000b003742e45c6famr6214599pgi.246.1646957539077; Thu, 10 Mar 2022 16:12:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1646957539; cv=none; d=google.com; s=arc-20160816; b=LccmNVOn31UH+cXVMzRxoG7jL/k0fFEJFMfi6KbE5/+vfRW31TBCqPgb81GacIQzbw uA5s4yqEAAijo3QK6wnhVQcXxXqZalIpVC64iZ9NpbLYyjjSK8H284efqQ+QS60Ff/96 Bu9bh6lrW1fdvPfO6N6jMxgCNtiRzCfI9JLKdZqO6EaKL5qJjKIA6h6jSGZCcYoakkd/ 8nAd2id7Gcnzar/t7b0vDHXMEIG608Ne/OlM/oCUVW+L4AnchbRa0RgwmT6mZxUORSiI tRJ8T0lQ5jTKyTh2TvCxpVlRQnn3KwLB37XpNKNkBY6MfMSfOCHg0RvMHfh8MWgccBbo tW3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=ckgh/54VKAw6Qnxgd+jgb5k0txhbSVaOhP9+nLif3j4=; b=vOGqwy+tM7Fn9Aq5ueS5zp5BFwARLgnXExjarqp1AMLjQNL4SXZlJvCUwzRjYtO2qM qMC/UnuRg20OCKIwpNjVii2SINbmaVBsllmGPLnrrb5VKfSuz0imuVK9ZNf3/nrXvPVV XyeQCZqbFqexytWj9WIwxuNLhAy1c7+YtJKgitCCw0rOr8pnqTHkKsn90ELRlWd88Tk0 DpQrHjXu2nK9xdf/Nr5qvUUD5n4rFv8cVGczt6boZZhV0lIx6sr5qn5rGsAtjqV4BaPh EEG8OsdWhHi/KuI2IrXA61TxJ90pkrHS17xoIscyPkSKnzbb5DHG/ZlXlYMTto7WKjZx Ylyg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=B3uvBSn7; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t9-20020a655549000000b00373c8d84a68si6894788pgr.82.2022.03.10.16.12.02; Thu, 10 Mar 2022 16:12:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=B3uvBSn7; dkim=neutral (no key) header.i=@suse.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243455AbiCJQdB (ORCPT + 99 others); Thu, 10 Mar 2022 11:33:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238790AbiCJQdA (ORCPT ); Thu, 10 Mar 2022 11:33:00 -0500 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6229E190C16; Thu, 10 Mar 2022 08:31:59 -0800 (PST) Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out1.suse.de (Postfix) with ESMTP id 160D821106; Thu, 10 Mar 2022 16:31:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1646929918; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ckgh/54VKAw6Qnxgd+jgb5k0txhbSVaOhP9+nLif3j4=; b=B3uvBSn76znSqOZimKCNoKHULtUje9t1w9TAl/MSQRejuXE1ujCmyUAb0+LeXbhBB8ZLAC jQvtBHO0vrmBIncL8JER8VU/uLNHZPu/t9jVMTRHtnwTuX1LZF3GjcaIMWgO56ZDo+Xrav t/e/+LHEKDA+xGlu0wgJ/eVEMF2lcJA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1646929918; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ckgh/54VKAw6Qnxgd+jgb5k0txhbSVaOhP9+nLif3j4=; b=V4kt/xeRGn5rhiPYx2cBdKqA7CcmeVGg3Ft6k1W5KRrfwKerbMwoXI+4ri5Jj7tf/YP1BV iSdYXYNInQEdwaAw== Received: from suse.de (unknown [10.163.32.246]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id 17676A3B83; Thu, 10 Mar 2022 16:31:56 +0000 (UTC) Date: Thu, 10 Mar 2022 16:31:54 +0000 From: Mel Gorman To: Nicolas Saenz Julienne Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, frederic@kernel.org, tglx@linutronix.de, mtosatti@redhat.com, linux-rt-users@vger.kernel.org, vbabka@suse.cz, cl@linux.com, paulmck@kernel.org, willy@infradead.org Subject: Re: [PATCH 0/2] mm/page_alloc: Remote per-cpu lists drain support Message-ID: <20220310163154.GF4363@suse.de> References: <20220208100750.1189808-1-nsaenzju@redhat.com> <20220303114550.GE4363@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 07, 2022 at 02:57:47PM +0100, Nicolas Saenz Julienne wrote: > > > Note that this is not the first attempt at fixing this per-cpu page lists: > > > - The first attempt[1] tried to conditionally change the pagesets locking > > > scheme based the NOHZ_FULL config. It was deemed hard to maintain as the > > > NOHZ_FULL code path would be rarely tested. Also, this only solves the issue > > > for NOHZ_FULL setups, which isn't ideal. > > > - The second[2] unanimously switched the local_locks to per-cpu spinlocks. The > > > performance degradation was too big. > > > > > > > For unrelated reasons I looked at using llist to avoid locks entirely. It > > turns out it's not possible and needs a lock. We know "local_locks to > > per-cpu spinlocks" took a large penalty so I considered alternatives on > > how a lock could be used. I found it's possible to both remote drain > > the lists and avoid the disable/enable of IRQs entirely as long as a > > preempting IRQ is willing to take the zone lock instead (should be very > > rare). The IRQ part is a bit hairy though as softirqs are also a problem > > and preempt-rt needs different rules and the llist has to sort PCP > > refills which might be a loss in total. However, the remote draining may > > still be interesting. The full series is at > > https://git.kernel.org/pub/scm/linux/kernel/git/mel/linux.git/ mm-pcpllist-v1r2 > > I'll have a proper look at it soon. > Thanks. I'm still delayed actually finishing the series as most of my time is dedicated to a separate issue. However, there is at least one bug in there at patch "mm/page_alloc: Remotely drain per-cpu lists" that causes a lockup under severe memory pressure. The fix is diff --git a/mm/page_alloc.c b/mm/page_alloc.c index c9a6f2b5548e..11b54f383d04 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -3065,10 +3065,8 @@ static int rmqueue_bulk(struct zone *zone, unsigned int order, */ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp) { - unsigned long flags; int to_drain, batch; - pcp_local_lock(&pagesets.lock, flags); batch = READ_ONCE(pcp->batch); to_drain = min(pcp->count, batch); if (to_drain > 0) { @@ -3076,7 +3074,6 @@ void drain_zone_pages(struct zone *zone, struct per_cpu_pages *pcp) free_pcppages_bulk(zone, to_drain, pcp, 0); spin_unlock(&pcp->lock); } - pcp_local_unlock(&pagesets.lock, flags); } #endif @@ -3088,16 +3085,12 @@ static void drain_pages_zone(unsigned int cpu, struct zone *zone) unsigned long flags; struct per_cpu_pages *pcp; - pcp_local_lock(&pagesets.lock, flags); - pcp = per_cpu_ptr(zone->per_cpu_pageset, cpu); if (pcp->count) { spin_lock(&pcp->lock); free_pcppages_bulk(zone, pcp->count, pcp, 0); spin_unlock(&pcp->lock); } - - pcp_local_unlock(&pagesets.lock, flags); } /*