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 B382AC433EF for ; Thu, 24 Mar 2022 19:00:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 136C06B0071; Thu, 24 Mar 2022 15:00:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E7CF6B0073; Thu, 24 Mar 2022 15:00:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EA2FB6B0074; Thu, 24 Mar 2022 15:00:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0179.hostedemail.com [216.40.44.179]) by kanga.kvack.org (Postfix) with ESMTP id DB77C6B0071 for ; Thu, 24 Mar 2022 15:00:04 -0400 (EDT) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 894B7182ACA31 for ; Thu, 24 Mar 2022 19:00:04 +0000 (UTC) X-FDA: 79280194728.25.31CA12B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id 9AD431C002C for ; Thu, 24 Mar 2022 19:00:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1648148401; 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=BEZsPU6ScEAA3keGh0hVCGrvQvsoW7+VZCfIyHrin5I=; b=Daow+UBDNifWDkAi60StB8XIn5qxrwgyer0k17sxtSyF6FXmGyEirK6i3DZktl0sy5Z4ap FJjBYaxUCQzlg0vZxu2cFXVGM4m60CaNFQSCTyMgpCRd1/fV47o7MYboyOR+LdXwUhayx6 uBduDKhNP/jxx8w5vdxWSNsNVoa08ec= 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-183-ZQh_TX1QP2a17bBA7QfMjQ-1; Thu, 24 Mar 2022 14:59:59 -0400 X-MC-Unique: ZQh_TX1QP2a17bBA7QfMjQ-1 Received: by mail-wm1-f70.google.com with SMTP id t2-20020a7bc3c2000000b003528fe59cb9so1901021wmj.5 for ; Thu, 24 Mar 2022 11:59:59 -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=BEZsPU6ScEAA3keGh0hVCGrvQvsoW7+VZCfIyHrin5I=; b=r2FhKNy+VjvB9T2sSqF/IngDVhdXn33pXVY4rKmuXkI2Nytol7+0ROKVJteiirVU59 9bk77AEaf7dSrKnsl6pxtkBoe7tzHEa+U/IHCkCGcwZfi1WVWqn32PifUIam/PNLd68p q+VbEqQQFjT0kZ+u71hgUe9dNztNDS/NCJP/J7xtI85Eyj38pCrWue7ILCArFaxgxz/n CsL6cEjdKfdnwGRsKBJsdRshjmWgD/ZBs2myoKdXNLy3vvsXgjKU+ibxjUwinM0U+5TH 5lPQ6vly3Yu7qnHpuUq9Q2qdJ9n2W4npL09JZSlh/fSs4C16M10HKYu35Umgy9mYlWZN zMYg== X-Gm-Message-State: AOAM530YmzrOL3JAlhUaIPpVmgr259TVbVNf2cOPGj8PNMgInnazBkx+ PfFn5G4L2ps+5O8N6z5+HtcfQ6mj96mOexvDEzCKONeYlJJCkf8KdyiMZV3UP/KRcVmUMfSOLmh IurAXUMPClLo= X-Received: by 2002:a5d:6101:0:b0:204:871e:9912 with SMTP id v1-20020a5d6101000000b00204871e9912mr5764246wrt.60.1648148398316; Thu, 24 Mar 2022 11:59:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw9rLBD0bceg0ZUAVQjV9g6B7JHVhv+FAZqMk/+BCNICmA66CnX4VjHlcEvcDu1+G+z22/Sng== X-Received: by 2002:a5d:6101:0:b0:204:871e:9912 with SMTP id v1-20020a5d6101000000b00204871e9912mr5764218wrt.60.1648148398054; Thu, 24 Mar 2022 11:59:58 -0700 (PDT) Received: from ?IPv6:2a0c:5a80:3506:3400:69b5:c807:1d52:ff67? ([2a0c:5a80:3506:3400:69b5:c807:1d52:ff67]) by smtp.gmail.com with ESMTPSA id 2-20020a056000154200b00203ee1fd1desm3442514wry.64.2022.03.24.11.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Mar 2022 11:59:57 -0700 (PDT) Message-ID: <3c24840e8378c69224974f321ec5c06a36a33dd3.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: Thu, 24 Mar 2022 19:59:56 +0100 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-Stat-Signature: bp476r7nntzdu5e5yzh6dgs4z8hdkf5j Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Daow+UBD; dmarc=pass (policy=none) header.from=redhat.com; spf=none (imf21.hostedemail.com: domain of nsaenzju@redhat.com has no SPF policy when checking 170.10.129.124) smtp.mailfrom=nsaenzju@redhat.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 9AD431C002C X-HE-Tag: 1648148401-387474 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: > 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 finally got some time to look at this and made some progress: First, I belive your 'mm-remotedrain-v2r1' results are wrong/inflated due= to a bug in my series. Essentially, all 'this_cpu_ptr()' calls should've been 'raw_cpu_ptr()' and your build, which I bet enables CONFIG_DEBUG_PREEMPT, wasted time trowing warnings about per-cpu variable usage with preemption enabled. Making the overall performance look worse than it actually is. M= y build didn't enable it, which made me miss this whole issue. I'm sorry fo= r the noise and time wasted on such a silly thing. Note that the local_lock to spin_lock conversion can handle the preeemption alright, it is part of th= e design[1]. As for your idea of not disabling interrupts in the hot paths, it seems t= o close the performance gap created by the lock conversion. That said, I'm = not sure I understand why you find the need to keep the local_locks around, n= ot only it casuses problems for RT systems, but IIUC they aren't really prot= ecting anything other than the 'this_cpu_ptr()' usage (which isn't really needed= ). I rewrote your patch on top of my lock conversion series and I'm in the pro= cess of testing it on multiple systems[2]. Let me know what you think. Thanks! [1] It follows this pattern: struct per_cpu_pages *pcp; pcp =3D raw_cpu_ptr(page_zone(page)->per_cpu_pageset); // <- Migration here is OK: spin_lock protects vs eventual pcplist // access from local CPU as long as all list access happens through the // pcp pointer. spin_lock(&pcp->lock); do_stuff_with_pcp_lists(pcp); spin_unlock(&pcp->lock); [2] See: git://git.kernel.org/pub/scm/linux/kernel/git/nsaenz/linux-rpi.git pcpd= rain-sl-v3r1 --=20 Nicol=C3=A1s S=C3=A1enz