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 55104C678D4 for ; Thu, 2 Mar 2023 20:53:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8BFEE6B0071; Thu, 2 Mar 2023 15:53:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 86FAE6B0073; Thu, 2 Mar 2023 15:53:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 736C16B0074; Thu, 2 Mar 2023 15:53:21 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 629996B0071 for ; Thu, 2 Mar 2023 15:53:21 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 29122AACD0 for ; Thu, 2 Mar 2023 20:53:21 +0000 (UTC) X-FDA: 80525158602.12.CD676F5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id 0DFEB18000E for ; Thu, 2 Mar 2023 20:53:17 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M0nm5xKg; spf=pass (imf24.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677790398; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=UFteTQZxv39AZEWRs/xshoWQSfK5OjMT5GVWCCENUyA=; b=ZQ88Ax8cDmZKcLk3habTAg6gAw+EzgSW50k8q0oxiES0oMhq/5feONwoa+pvz/DB44+zpd pe2NyK3oAFTgoj+8DeeszTgQtVF+j9Vz/ac0T1FZ4/ujPxFzyDKLNmdb2y4rZ5wIYxnItM wnzEcy03NY7y6Jn9BEwk3ulNP2H+TBc= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M0nm5xKg; spf=pass (imf24.hostedemail.com: domain of peterx@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=peterx@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677790398; a=rsa-sha256; cv=none; b=LlwoIFk6hijg8dRzGks+cV/nnhrYgRk4GtwsTSMPxbY3PJ+H+dV1gPix+m4vMCiGiKXEcV 8tYnpnc3YE45RxRKueOLQDi0jnmUVZIqT/NCvsaYFiu56NnzbzWaQwyBGjmo25rvLGj6W9 /RwJHSJaqxzFXvT437VIto8ikNEKPbY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677790397; 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: in-reply-to:in-reply-to:references:references; bh=UFteTQZxv39AZEWRs/xshoWQSfK5OjMT5GVWCCENUyA=; b=M0nm5xKgaqwj5WmXp/YkVka5rGeFifLdtjVwF9XVkVDOYXjld7yW1LnRWTG/3p41AoqKDA p99Tpg2z6idriEC7VhnKGxXWaDzsrHYHU1YciNybPPISZA9Gykndc8K3AK1FPP9YBU5PPJ Cj098g61aniTMolxzxEUV4qfMxAjLHw= Received: from mail-qk1-f197.google.com (mail-qk1-f197.google.com [209.85.222.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-417-giqGYM0QNge6JSV4Zdbk0g-1; Thu, 02 Mar 2023 15:53:14 -0500 X-MC-Unique: giqGYM0QNge6JSV4Zdbk0g-1 Received: by mail-qk1-f197.google.com with SMTP id b22-20020ae9eb16000000b007427f9339c0so140874qkg.17 for ; Thu, 02 Mar 2023 12:53:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1677790394; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=UFteTQZxv39AZEWRs/xshoWQSfK5OjMT5GVWCCENUyA=; b=hALvFJLsyAPsoFxEAnDJgNwC825r5W8KGNQWRI/a2T7l1pgbl5J+DY9/53qDwkcmpo IPrv2/9h4x4YSf0lhxeMayDpM+jJkvtV93LcM3w1O9jTSGqkwvJ5lQl9gLjdnxyAVQpK e87XRSJW4KRGJZCfxX8qDMIPvM1ZrhGWxokBL+3JbBuC+zCMPM8o1zDfn0iMPky+cope diHr0kwWn0lRMi7NtArP4wS+1T9SELPEE7yyrrcx2zJuTInZ0gB0Tf6oiDGDGnVYLRSU NDwAq2cWdcI7EG98cRTIxRR/fu5yGi1QqejMS7dwTvcTBf9KqnEqxvoMDC22K241K8vE m6PQ== X-Gm-Message-State: AO0yUKWKzpve5V8ne2w0EH3nggC0h2MG+bh0NoOcXslRc8605Y9UlX4Z OBHiWxoT6pgHBZ6aIhNns8FTc3I+wZg3RrAL4WBuaOi2gbBat6p05iU+zMzpVAG19I/fshrO73K XKrZz/VHnlKI= X-Received: by 2002:a05:622a:1391:b0:3bf:c458:5bac with SMTP id o17-20020a05622a139100b003bfc4585bacmr22136401qtk.0.1677790393866; Thu, 02 Mar 2023 12:53:13 -0800 (PST) X-Google-Smtp-Source: AK7set/NOvojMFNnz7QT8jO4gKy6syuG1bvbocLVVPCmqIPO33iixEInIIUB6d6JLey/Olnx34XtXg== X-Received: by 2002:a05:622a:1391:b0:3bf:c458:5bac with SMTP id o17-20020a05622a139100b003bfc4585bacmr22136378qtk.0.1677790393613; Thu, 02 Mar 2023 12:53:13 -0800 (PST) Received: from x1n (bras-base-aurron9127w-grc-56-70-30-145-63.dsl.bell.ca. [70.30.145.63]) by smtp.gmail.com with ESMTPSA id a190-20020a3798c7000000b00742aff9574asm363408qke.65.2023.03.02.12.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Mar 2023 12:53:13 -0800 (PST) Date: Thu, 2 Mar 2023 15:53:12 -0500 From: Peter Xu To: Marcelo Tosatti Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 02/11] this_cpu_cmpxchg: ARM64: switch this_cpu_cmpxchg to locked, add _local function Message-ID: References: <20230209150150.380060673@redhat.com> <20230209153204.683821550@redhat.com> MIME-Version: 1.0 In-Reply-To: <20230209153204.683821550@redhat.com> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: pau769bfumsakz6kq7ayk8rn5n69sxcy X-Rspamd-Queue-Id: 0DFEB18000E X-HE-Tag: 1677790397-700991 X-HE-Meta: U2FsdGVkX18SnuZlockRPOTwQX4dRQ0z/m5NOdEEB3djtA1L1sNfb8A9FsYwrse5eKm+hZtuGA+ZqDl0G54cIl9aAkFt3wPomsBohspk9LqDkmMiLUPZEhwukLaNNRUXpI+qZfDkKcA02Yib7FX4qp40FmyYK6DZAwc7RJybRMxgpxS3OQBWNoDNqM9Eb21hm9e3Xlhbobo25dtehfTQ7bP7cK1gOc3yWHR1hxsHtzgHzye+boTqBO3cm2fZh54L53wVenK+5VjQ1ZsLNUr1mBcR+QSwQQ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M5Z+aVm/aYrzjoxZP6S8soweLu3GipuLIQKI4mbKp9NBUfCx7X3tX0Al5mR5MxzaWPBe9gGHIkAoN X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Feb 09, 2023 at 12:01:52PM -0300, Marcelo Tosatti wrote: > Goal is to have vmstat_shepherd to transfer from > per-CPU counters to global counters remotely. For this, > an atomic this_cpu_cmpxchg is necessary. > > Following the kernel convention for cmpxchg/cmpxchg_local, > change ARM's this_cpu_cmpxchg_ helpers to be atomic, > and add this_cpu_cmpxchg_local_ helpers which are not atomic. I can follow on the necessity of having the _local version, however two questions below. > > Signed-off-by: Marcelo Tosatti > > Index: linux-vmstat-remote/arch/arm64/include/asm/percpu.h > =================================================================== > --- linux-vmstat-remote.orig/arch/arm64/include/asm/percpu.h > +++ linux-vmstat-remote/arch/arm64/include/asm/percpu.h > @@ -232,13 +232,23 @@ PERCPU_RET_OP(add, add, ldadd) > _pcp_protect_return(xchg_relaxed, pcp, val) > > #define this_cpu_cmpxchg_1(pcp, o, n) \ > - _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) > + _pcp_protect_return(cmpxchg, pcp, o, n) > #define this_cpu_cmpxchg_2(pcp, o, n) \ > - _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) > + _pcp_protect_return(cmpxchg, pcp, o, n) > #define this_cpu_cmpxchg_4(pcp, o, n) \ > - _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) > + _pcp_protect_return(cmpxchg, pcp, o, n) > #define this_cpu_cmpxchg_8(pcp, o, n) \ > + _pcp_protect_return(cmpxchg, pcp, o, n) This makes this_cpu_cmpxchg_*() not only non-local, but also (especially for arm64) memory barrier implications since cmpxchg() has a strong memory barrier, while the old this_cpu_cmpxchg*() doesn't have, afaiu. Maybe it's not a big deal if the audience of this helper is still limited (e.g. we can add memory barriers if we don't want strict ordering implication), but just to check with you on whether it's intended, and if so whether it may worth some comments. > + > +#define this_cpu_cmpxchg_local_1(pcp, o, n) \ > _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) > +#define this_cpu_cmpxchg_local_2(pcp, o, n) \ > + _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) > +#define this_cpu_cmpxchg_local_4(pcp, o, n) \ > + _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) > +#define this_cpu_cmpxchg_local_8(pcp, o, n) \ > + _pcp_protect_return(cmpxchg_relaxed, pcp, o, n) I think cmpxchg_relaxed()==cmpxchg_local() here for aarch64, however should we still use cmpxchg_local() to pair with this_cpu_cmpxchg_local_*()? Nothing about your patch along since it was the same before, but I'm wondering whether this is a good time to switchover. The other thing is would it be good to copy arch-list for each arch patch? Maybe it'll help to extend the audience too. Thanks, -- Peter Xu