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 8E7CDC678D4 for ; Thu, 2 Mar 2023 10:51:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23DAC6B0074; Thu, 2 Mar 2023 05:51:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1ED096B0075; Thu, 2 Mar 2023 05:51:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B5C56B0078; Thu, 2 Mar 2023 05:51:25 -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 EF5F66B0074 for ; Thu, 2 Mar 2023 05:51:24 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id AF086AB715 for ; Thu, 2 Mar 2023 10:51:24 +0000 (UTC) X-FDA: 80523641688.05.93DCCB7 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 89AF1100010 for ; Thu, 2 Mar 2023 10:51:22 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="BhrDD/8H"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1677754282; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=D/i6gxIWosvIGHKIV9tT99VnPhRuzzCj/xoLbIkHVCg=; b=w6sGemTFDuukVBzHwiBIiF6RXA8r65EffFQ25bFSakrUD8JX8uQnDJU4kS/ptQ3I4MNvZE JCwyFr1rA/38oYpIGLAwaml3OAOmMRRZrxmx/56K4BJmPCKPZ0EediEi2nLmS81qjGoeer hvbcLYaWRr2dmcpRDOIu9eWEcgOOqNk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="BhrDD/8H"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf05.hostedemail.com: domain of david@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=david@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677754282; a=rsa-sha256; cv=none; b=XVcqzCeTZBKOXi6+RCJVqxxsAlzYxS06RH0OcxIlPTXUz3D4TaS4A1b14KGNej0DcFny75 /jVvrWJILM4nQjYvzgeCAjrhgQLy+etCuMCMiRHGYo1WT5iHDv5fChWZ0xgPnleIT7WuuN 4dM2VkUQzRikIY1YSYIPHDaEu/DsPjI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677754281; 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=D/i6gxIWosvIGHKIV9tT99VnPhRuzzCj/xoLbIkHVCg=; b=BhrDD/8HOaTX7q98wZdRdVwvejzUaCbazUUkFST5yuCBL2wZrPY1BcQcXA/eEn0kUo0G1O zUObZle7O6AeuMvF3caY/jGbSKcDDvOeHJN6As1ffb/C5zjvsxZmCUgAo+O8u4mOngJxG8 NDl9LPUAKqmrdSGRH06CWBt4jr74Hto= 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.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-272-bWpSxlIsNV-oKu0sSq0lyg-1; Thu, 02 Mar 2023 05:51:20 -0500 X-MC-Unique: bWpSxlIsNV-oKu0sSq0lyg-1 Received: by mail-wm1-f70.google.com with SMTP id k20-20020a05600c1c9400b003e2249bd2b4so5595262wms.5 for ; Thu, 02 Mar 2023 02:51:20 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:organization:references:cc:to :from:content-language:subject:user-agent:mime-version:date :message-id:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D/i6gxIWosvIGHKIV9tT99VnPhRuzzCj/xoLbIkHVCg=; b=6B7mxf4laXnN5uS8mLFNMPnvgJ+bd3q6I0hFCwbIpBiX8YFUms/pqYRl2LICAxg2ee C/sUANl68rBpqsTTmxvmabwP3GeufthwL88Lkpmdy2dReClkZtFfBDhtg9W3o8NkJAyg oJjeDcgmFFX4Z0sKdmSzFbGuDMkzcNcaY0ZC71klDqt3nl+II5hPrhrJJ9vPSGAuIT6N 2yVjVdZmskhbXo4n2MQSg1kPUt68J12mDFVIhEYOSYJQOcJ1SdPePRpebtb8C35Fnc3R FQmLTvLxhCjbzr75jMJNCfZ9dS+2EG2g7hpgP6i4i+5a/SvRpM4ywCxCCsKNYXZUaOe2 1x4g== X-Gm-Message-State: AO0yUKVgaOf1mr/cIjYtjawOBrO+noGVe9S2c8y7S1PCeXWW0BAAwxWI nAFH+hsuaT647TdPL40Xg/biejXgpzL4EdlLEn7l90niB1Cz6VrOZhCab8aQCKDex51fFGSXGzf yQAm/3CxwjXrCAVsf X-Received: by 2002:adf:ea52:0:b0:2cd:cf97:61c9 with SMTP id j18-20020adfea52000000b002cdcf9761c9mr1176803wrn.4.1677754279578; Thu, 02 Mar 2023 02:51:19 -0800 (PST) X-Google-Smtp-Source: AK7set9d3NoWdP2p+73heAEbqclshz4F9tooFLTmi1dsXWlVPSDATuOksmc0KKFANSBrjBII1k/7qQ== X-Received: by 2002:adf:ea52:0:b0:2cd:cf97:61c9 with SMTP id j18-20020adfea52000000b002cdcf9761c9mr1176791wrn.4.1677754279229; Thu, 02 Mar 2023 02:51:19 -0800 (PST) Received: from ?IPV6:2003:cb:c70e:4f00:87ba:e9e9:3821:677b? (p200300cbc70e4f0087bae9e93821677b.dip0.t-ipconnect.de. [2003:cb:c70e:4f00:87ba:e9e9:3821:677b]) by smtp.gmail.com with ESMTPSA id s11-20020a5d424b000000b002c55521903bsm14779464wrr.51.2023.03.02.02.51.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Mar 2023 02:51:18 -0800 (PST) Message-ID: Date: Thu, 2 Mar 2023 11:51:17 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.8.0 Subject: Re: [PATCH v2 02/11] this_cpu_cmpxchg: ARM64: switch this_cpu_cmpxchg to locked, add _local function From: David Hildenbrand To: Marcelo Tosatti , Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20230209150150.380060673@redhat.com> <20230209153204.683821550@redhat.com> Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 89AF1100010 X-Stat-Signature: ajq1xrh3ajdrp9i5hamo6rhdg3a8xmbz X-HE-Tag: 1677754282-490158 X-HE-Meta: U2FsdGVkX1+b5Fm4dg4ADZhvj77a0kVmuR0TbdHTSnxFSaZ/o1HUqxLCMSJyQWCFRySugoZ+4kts6OVTYczdD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6r1bghEGfxxIaXb1DctYAADajHbvqD8AAHxWJxMGVGUXRDBiCjAQAYvjHX/T3yoZyduYGZu+xuexBR+aTlhEtesv7BFbL23wewPuRWVzyxaUdmWd5241o4F+KiuPllY59NGDl0INb1zqlQvFPdF1JL29xas2U4bXVxwlxOFkrblr+9XXDrASyVHpe0M9JFtThkUe6aNcFA== 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: On 02.03.23 11:42, David Hildenbrand wrote: > On 09.02.23 16:01, 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. >> >> 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) >> + >> +#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) >> + > > Call me confused (not necessarily your fault :) ). > > We have cmpxchg_local, cmpxchg_relaxed and cmpxchg. > this_cpu_cmpxchg_local_* now calls ... *drumroll* ... cmpxchg_relaxed. > > IIUC, cmpxchg_local is only guaranteed to be atomic WRO the current CPU > (especially, protection against interrupts when the operation is > implemented using multiple instructions). We do have a generic > implementation that disables/enables interrupts. > > IIUC, cmpxchg_relaxed an atomic update without any memory ordering > guarantees (in contrast to cmpxchg, cmpxchg_acquire, cmpxchg_acquire). > We default to arch_cmpxchg if we don't have arch_cmpxchg_relaxed. > arch_cmpxchg defaults to arch_cmpxchg_local, if not supported. > > > Naturally I wonder: > > (a) Should these new variants be rather called > this_cpu_cmpxchg_relaxed_* ? > > (b) Should these new variants rather call the "_local" variant? > > > Shedding some light on this would be great. Nevermind, looking at the other patches I realized that this is arch-specific. Other archs that have _local variants call the _local variants. So I assume we really want the name this_cpu_cmpxchg_local_*, and using _relaxed here is just the aarch64 way of implementing _local via _relaxed. Confusing :) -- Thanks, David / dhildenb