From patchwork Tue Mar 14 18:59:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13174926 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 08D76C7618B for ; Tue, 14 Mar 2023 19:01:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 23C4C8E0003; Tue, 14 Mar 2023 15:01:13 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EC188E0001; Tue, 14 Mar 2023 15:01:13 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EE45B8E0006; Tue, 14 Mar 2023 15:01:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C9D3C8E0003 for ; Tue, 14 Mar 2023 15:01:12 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 83E35160D76 for ; Tue, 14 Mar 2023 19:01:11 +0000 (UTC) X-FDA: 80568421542.08.9059B71 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id B88EE1C000E for ; Tue, 14 Mar 2023 19:01:08 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fK+KM5+R; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1678820468; 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: references:references:dkim-signature; bh=iUvNynje4NLXuVViJqGVXz34mfwfY1r+EmC29iXiBlQ=; b=Jg/RLVVN/F0Trf+PuCMoD1b9eH0tRkmDs3+VgQ4G5ckWacyPIK0xQpaLHxfVj8U/7ed4mc hI9P7YkSNTTIuZF9Yqz/T3CLqu/UD0jng6sqMo13m90KkRSQEaA6EfPMI/mWZVpV1Vo7Rl bBh/Ol7RKWFZywQLz8PN/APhU3Wn/Ao= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fK+KM5+R; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf18.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1678820468; a=rsa-sha256; cv=none; b=g0PBfi0niAKeIBbewIAVRRtl4BuwwJUdhSyBfnaqmehP6nnrtKAJ7uiAmZe+XAZWixDwYJ xxaZH0I6e95et2mAzByM42R/dwerkYb7DRjkZiI74AC3wK9gf6Otclhzk+Jo4UJcnUuNZ2 1w3gVIMLtrtLhyeQwcD8KKEF6ze+8kA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678820467; 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: references:references; bh=iUvNynje4NLXuVViJqGVXz34mfwfY1r+EmC29iXiBlQ=; b=fK+KM5+R4E3aI5+1vDafYAkDkOYtzPSeqARJJMUdNwjLAoH+g4n62+St2V0BNNVP4aou+1 4S0bNZlIlYXE1ksZXuFLs7slAfqqlgEyhNxQhOtSZMEgtkfox7sW5DriadPVhWgKn+0/1H 6AaBKoe8g95qltD/Q5NjLufoTZpoxcI= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-456-I9tNzClcMYS_EvR0ZH9ndw-1; Tue, 14 Mar 2023 15:01:04 -0400 X-MC-Unique: I9tNzClcMYS_EvR0ZH9ndw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5E48928004F8; Tue, 14 Mar 2023 19:01:03 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-2.gru2.redhat.com [10.97.112.2]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D7681121315; Tue, 14 Mar 2023 19:01:03 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 555DF4039C284; Tue, 14 Mar 2023 16:00:44 -0300 (-03) Message-ID: <20230314185951.551375754@redhat.com> User-Agent: quilt/0.67 Date: Tue, 14 Mar 2023 15:59:15 -0300 From: Marcelo Tosatti To: Christoph Lameter Cc: Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Russell King , Huacai Chen , Heiko Carstens , x86@kernel.org, Vlastimil Babka , Michal Hocko , Marcelo Tosatti Subject: [PATCH v6 01/12] this_cpu_cmpxchg: ARM64: switch this_cpu_cmpxchg to locked, add _local function References: <20230314185914.836510860@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspamd-Queue-Id: B88EE1C000E X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: q7rcueuxybn7ozgzifq81kedtw8d7b4g X-HE-Tag: 1678820468-42596 X-HE-Meta: U2FsdGVkX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MPm7/nZiX0wI3p1VzKw1TZ5pIbtRF9h6MLzJ28kmyKhMzn0eCiXJt1ww0/vyO3N5Izz121nt+SOa11Wbtmr0wNmAE1UjCWtK9RX6udrzR0BjT9st58SIpziXoGXwKJBGv1fQZ17nh3G0Pdbiv2vA== 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: 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) + #ifdef __KVM_NVHE_HYPERVISOR__ extern unsigned long __hyp_per_cpu_offset(unsigned int cpu);