From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CAACAC433EF for ; Wed, 30 Mar 2022 11:29:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 189AE8D0002; Wed, 30 Mar 2022 07:29:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 13B228D0001; Wed, 30 Mar 2022 07:29:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1CE48D0002; Wed, 30 Mar 2022 07:29:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id E27B58D0001 for ; Wed, 30 Mar 2022 07:29:15 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 911901828A80C for ; Wed, 30 Mar 2022 11:29:15 +0000 (UTC) X-FDA: 79300831470.31.9E74052 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 088CD40016 for ; Wed, 30 Mar 2022 11:29:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648639754; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yaxx7Mi+hRPrFxRT4XMjZarJbz28r/Aqr9FeS7C1aeM=; b=TsBHukO71r3kLcxYmJW8Us5M9W225RjRuZSmfpnzBizXmVpQvlSfu3dncfq9nMX0DKn180 24BgiMm0a0B8hXaXoabRb4skpwD0mIWuy560K2jutMOb8r4ULrY7CF4J/y5sQ77iq8TYzE 4t8IH+AK5sYaVI1bL++8J7bzezJgPmY= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-41-md1vS6ulPui9tM6gftxsdw-1; Wed, 30 Mar 2022 07:29:07 -0400 X-MC-Unique: md1vS6ulPui9tM6gftxsdw-1 Received: by mail-wm1-f70.google.com with SMTP id c126-20020a1c3584000000b00380dee8a62cso7776396wma.8 for ; Wed, 30 Mar 2022 04:29:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:user-agent:mime-version:content-transfer-encoding; bh=yaxx7Mi+hRPrFxRT4XMjZarJbz28r/Aqr9FeS7C1aeM=; b=PlJak26CCWZXD960l9ycGBN5JFksayjX7YCqJdJxswgCp3LLXvDW7K0BvTDHTLJm8o /JmeyFUML9wctAUAeJNLZimbRK+la4hWTnYXsnhpLu0UFO8vW0ianM5mZFeRW+BV/8tx rNNbzUCQdt0kL2dRP3RxPcw0Bqp2b0jeDNP04Qlsq8JcdGVvJlWqWfnQGWKyVuYPfdpU BH4i6ySodqUB1qY3gje6DMi4vhK0B1DXchmTGBrucsoXKld4vd4Y0kjKKrrlG7Vr3+NQ k48Juo8PvynWvnckH9TkRdt2lIbQa9BlZPoJXDeCGpzKuhAvF72lBl+NDm5dH17ZcY0S QuyA== X-Gm-Message-State: AOAM530f1eKPN+BlSFhxF16l97DQlS1hsRiNYBRW2hsfkwSst8OOhvS1 GO+OpTQ31zYut7xNI5eONR5wkIMdd3C1tiTe9MIqbOJSZDZidjJJDOPbq8kwdsVBOif/pwE9EPr olWag4WGBEjo= X-Received: by 2002:a1c:f211:0:b0:381:6c60:742f with SMTP id s17-20020a1cf211000000b003816c60742fmr4110599wmc.130.1648639746485; Wed, 30 Mar 2022 04:29:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz3tJfjg2ltNgBDJTjAI6UNvach4o9T1u3xP9F0MW35LlWoSLgV4PaG9kYJkXDGXk8iOPzXyQ== X-Received: by 2002:a1c:f211:0:b0:381:6c60:742f with SMTP id s17-20020a1cf211000000b003816c60742fmr4110575wmc.130.1648639746177; Wed, 30 Mar 2022 04:29:06 -0700 (PDT) Received: from ?IPv6:2a0c:5a80:1c1a:5300:ea85:f79:5235:c7fc? ([2a0c:5a80:1c1a:5300:ea85:f79:5235:c7fc]) by smtp.gmail.com with ESMTPSA id bg18-20020a05600c3c9200b0037c2ef07493sm5273322wmb.3.2022.03.30.04.29.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 30 Mar 2022 04:29:05 -0700 (PDT) Message-ID: <7d115ec39714b906e31398373855c28391229ff9.camel@redhat.com> Subject: Re: [PATCH 0/2] mm/page_alloc: Remote per-cpu lists drain support From: Nicolas Saenz Julienne To: Mel Gorman 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 Date: Wed, 30 Mar 2022 13:29:04 +0200 In-Reply-To: <20220303114550.GE4363@suse.de> References: <20220208100750.1189808-1-nsaenzju@redhat.com> <20220303114550.GE4363@suse.de> User-Agent: Evolution 3.42.4 (3.42.4-1.fc35) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" X-Rspam-User: Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=TsBHukO7; spf=none (imf04.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=nsaenzju@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 088CD40016 X-Stat-Signature: 94xa4fp7t7bf7t79qxuw456xu9owu5pq X-HE-Tag: 1648639754-186904 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Mel, On Thu, 2022-03-03 at 11:45 +0000, Mel Gorman wrote: > On Tue, Feb 08, 2022 at 11:07:48AM +0100, Nicolas Saenz Julienne wrote: > > This series replaces mm/page_alloc's per-cpu page lists drain mechani= sm with > > one that allows accessing the lists remotely. Currently, only a local= CPU is > > permitted to change its per-cpu lists, and it's expected to do so, on= -demand, > > whenever a process demands it by means of queueing a drain task on th= e local > > CPU. This causes problems for NOHZ_FULL CPUs and real-time systems th= at can't > > take any sort of interruption and to some lesser extent inconvenience= s idle and > > virtualised systems. > >=20 >=20 > I know this has been sitting here for a long while. Last few weeks have > not been fun. >=20 > > Note that this is not the first attempt at fixing this per-cpu page l= ists: > > - The first attempt[1] tried to conditionally change the pagesets lo= cking > > 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 spin= locks. The > > performance degradation was too big. > >=20 >=20 > 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 proble= m > 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 ma= y > still be interesting. The full series is at > https://git.kernel.org/pub/scm/linux/kernel/git/mel/linux.git/ mm-pcpll= ist-v1r2 >=20 > It's still waiting on tests to complete and not all the changelogs are > complete which is why it's not posted. >=20 > This is a comparison of vanilla vs "local_locks to per-cpu spinlocks" > versus the git series up to "mm/page_alloc: Remotely drain per-cpu list= s" > for the page faulting microbench I originally complained about. The te= st > machine is a 2-socket CascadeLake machine. >=20 > pft timings > 5.17.0-rc5 5.17.0-rc5 = 5.17.0-rc5 > vanilla mm-remotedrain-v2r1 = mm-pcpdrain-v1r1 > Amean elapsed-1 32.54 ( 0.00%) 33.08 * -1.66%* = 32.82 * -0.86%* > Amean elapsed-4 8.66 ( 0.00%) 9.24 * -6.72%* = 8.69 * -0.38%* > Amean elapsed-7 5.02 ( 0.00%) 5.43 * -8.16%* = 5.05 * -0.55%* > Amean elapsed-12 3.07 ( 0.00%) 3.38 * -10.00%* = 3.09 * -0.72%* > Amean elapsed-21 2.36 ( 0.00%) 2.38 * -0.89%* = 2.19 * 7.39%* > Amean elapsed-30 1.75 ( 0.00%) 1.87 * -6.50%* = 1.62 * 7.59%* > Amean elapsed-48 1.71 ( 0.00%) 2.00 * -17.32%* = 1.71 ( -0.08%) > Amean elapsed-79 1.56 ( 0.00%) 1.62 * -3.84%* = 1.56 ( -0.02%) > Amean elapsed-80 1.57 ( 0.00%) 1.65 * -5.31%* = 1.57 ( -0.04%) >=20 > Note the local_lock conversion took 1 1-17% penalty while the git tree > takes a negligile penalty while still allowing remote drains. It might > have some potential while being less complex than the RCU approach. I've been made aware of a problem with the spin_trylock() approach. It do= esn't work for UP since in that context spin_lock() is a NOOP (well, it only di= sables preemption). So nothing prevents a race with an IRQ. It's kinda funny, breakages generally happen the other way around. Regards, --=20 Nicol=C3=A1s S=C3=A1enz