From patchwork Mon May 15 18:00:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 94267 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp7102193vqo; Mon, 15 May 2023 11:08:36 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5wuzS9jDay2rKZPdUbXRkWloI34P04NxtnLTwGdrSOwMODfzVPw6MUPLgADAF6pW2EuP+5 X-Received: by 2002:a05:6a00:2189:b0:63d:4446:18ab with SMTP id h9-20020a056a00218900b0063d444618abmr42780249pfi.23.1684174116565; Mon, 15 May 2023 11:08:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684174116; cv=none; d=google.com; s=arc-20160816; b=CYckCvHXaI+gOzlMcoQZebgXyCPb5Th3DsvweDVYcaodgJxpE2TuFV7Stj2ae6WP1M hDTZ8TFFmWQdtfOpYi9SZ7AzXtSh+u0yZNWI7mf820g+v0vMMM7aPDtaQErx++YD/jZM 4KIbxPqQaTreSdAMyt5f7iV7JKoIy6pA78TDehCNGT/rK/o4l9kJpT5V0MVFFyxHw77b NrsqtxP8CAZe1VSVwHEILkrrbVm1KUjbcJb9jc3OplPiePEkFwA0ufkPqmG5o6pfVD7Q rnPVEckxps3tovTmtr63OJRx8pwrLVfCqQXEDxuqq5bfUeT4EBzHEEX8CyV2rISk3nda q7Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:subject:cc:to:from:date :user-agent:message-id:dkim-signature; bh=418Es5nqdsliVmHbTuXzLvQQdVHfWzYdcac5+iWJU4U=; b=zEzfU+EPD0sLD1k3Iu3r5hYhhrTd7StvbBj6I4mVuan7iBOfZ7ShK4Jw5DKcIifZFh JIRkT+4QHc69oS3WuDWcHe2wCkDp5GH7OypxohSamp8KP92IhwldjE+pR3NqyUVM+M/D MMVjB3bceZTo0qUqFSKqLqbmDFRA9ggntrA50vVqAxRPLwpooeub6oqMTSG7IGp3ra3h PUExt+pZacoBC1kHl3mczMnkFbC8fL0YNffsC2qe1uH7atbozCVLLXK+jRslPpdOVmnl TkoINrKdCOixadgvkiajGn96Wt6otKC/ABKeqhwC1zyo4H85/z7Nf9/o8Dgn4v+OL6FV 6Yhw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YQqwe93Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d22-20020aa797b6000000b0063b8b7d7a14si16910946pfq.70.2023.05.15.11.08.21; Mon, 15 May 2023 11:08:36 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YQqwe93Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245102AbjEOSHj (ORCPT + 99 others); Mon, 15 May 2023 14:07:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244716AbjEOSGr (ORCPT ); Mon, 15 May 2023 14:06:47 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 360D11CBA2 for ; Mon, 15 May 2023 11:03:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684173828; 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=418Es5nqdsliVmHbTuXzLvQQdVHfWzYdcac5+iWJU4U=; b=YQqwe93QNXKVLVR2pog8ka5UKRU78mtPDcz3WjMlCum1gCzJmBHvr4ZudfmYQEoI5qXBqD mQ2nBGkbJDLFPfk6ErK1zhMTaJLsVICWDYExrwx3hZdMKTuv2qn0dRtmtqOHX9LR4ubBc8 VutM1xAyE5ozn63FZYtsGkmRo613fHw= 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-351-yD2GRHLLNGCGNdDrFnss0w-1; Mon, 15 May 2023 14:03:43 -0400 X-MC-Unique: yD2GRHLLNGCGNdDrFnss0w-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27ED93C0ED4A; Mon, 15 May 2023 18:03:43 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-4.gru2.redhat.com [10.97.112.4]) by smtp.corp.redhat.com (Postfix) with ESMTPS id F1701492B00; Mon, 15 May 2023 18:03:42 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 44A8A4161E523; Mon, 15 May 2023 15:02:17 -0300 (-03) Message-ID: <20230515180138.467548391@redhat.com> User-Agent: quilt/0.67 Date: Mon, 15 May 2023 15:00:17 -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 v8 02/13] this_cpu_cmpxchg: ARM64: switch this_cpu_cmpxchg to locked, add _local function References: <20230515180015.016409657@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1765984558713016073?= X-GMAIL-MSGID: =?utf-8?q?1765984558713016073?= 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);