From patchwork Fri Mar 3 19:58:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13159454 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 BB582C64EC4 for ; Fri, 3 Mar 2023 20:00:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07C096B0082; Fri, 3 Mar 2023 15:00:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 02B7F6B0083; Fri, 3 Mar 2023 15:00:41 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E11E86B0085; Fri, 3 Mar 2023 15:00:41 -0500 (EST) 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 B8E5C6B0083 for ; Fri, 3 Mar 2023 15:00:41 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8BED181331 for ; Fri, 3 Mar 2023 20:00:41 +0000 (UTC) X-FDA: 80528654682.14.FF6F322 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 CECE8100016 for ; Fri, 3 Mar 2023 20:00:39 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LHQZ8E0q; spf=pass (imf05.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@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=1677873639; 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=YjZzxvwbzUGJAOWGom5FEayhMjnpZ78I4D4VtdieNs8=; b=27WclZtc89zgJ5b+/4oYMSvnltgUxhnun+2P8LTC3/kjrJCFeR+YEjoccmQ9qBeqgVOg+n jz3ibbCj4o7yaHYwINhjnkB1d+JB1KiwgVFapgbS4Q/nt5z/FMeBI8CZKcCT5Z6cJNhSIt 9EPqc2+uhKvgkrAd9UJPM2v239p5CbY= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LHQZ8E0q; spf=pass (imf05.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mtosatti@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1677873639; a=rsa-sha256; cv=none; b=VdtHe/6R9lTwk2dPCarXBVKIOO0iLjgZejQvZv+832el6P+3/Zuwr5q5MtxmvWz+dgHSEM hCTRR2NuYiagpwnuH/TS+MS36zyprxv3MKXPniu4pARsIOhJj5lLNFXXs0pibRNx/Y+yOF z50G10meKMilAUXxxlzCkLPmMELqyIw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677873639; 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=YjZzxvwbzUGJAOWGom5FEayhMjnpZ78I4D4VtdieNs8=; b=LHQZ8E0qRTdKgK+K9SgZ5gx5RZNHgpAPj4JjIlWxflC7Q9k2SL4Umr/Y36ml2Hq2o+7zeI Y5CInG2DXpe9BfqdsamGqARaG605UyZ4b4UU/LFYP0lRtG1NT9GoyHYzPsLyJvqkAYpSsi 0oEkLKgfgb9czoFe426NPwUPBUtwErE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-600-0hR5pFVRPFKmnp7Mr7Vb7w-1; Fri, 03 Mar 2023 15:00:33 -0500 X-MC-Unique: 0hR5pFVRPFKmnp7Mr7Vb7w-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C821101B44E; Fri, 3 Mar 2023 20:00:32 +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 2D92C4014EB9; Fri, 3 Mar 2023 20:00:32 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id ABA1542919632; Fri, 3 Mar 2023 17:00:12 -0300 (-03) Message-ID: <20230303195908.977788434@redhat.com> User-Agent: quilt/0.67 Date: Fri, 03 Mar 2023 16:58:50 -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, Marcelo Tosatti Subject: [PATCH v3 09/11] mm/vmstat: use xchg in cpu_vm_stats_fold References: <20230303195841.310844446@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: CECE8100016 X-Stat-Signature: gyp8hshum18fcupiy9wyo63ujjedt8nc X-Rspam-User: X-HE-Tag: 1677873639-387474 X-HE-Meta: U2FsdGVkX1/I/TjzXRC4BErPy1COqp+z0l7JjZTKZfSJ+YTUd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4kG9Ze1t3OPwuefE0p7xluTccZUXN5Sf6nVrCXplkZtOrFqgGidihnDzltuqugXrEdwiQOhI49zc9RetCnb5MIT+LnBbCin+UPEUoLxJmwIOEg6e0M0v+kTWbMu7fojrin2qMCHE9btkOjKAcFTDZiOu0= 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: In preparation to switch vmstat shepherd to flush per-CPU counters remotely, use xchg instead of a pair of read/write instructions. Signed-off-by: Marcelo Tosatti Index: linux-vmstat-remote/mm/vmstat.c =================================================================== --- linux-vmstat-remote.orig/mm/vmstat.c +++ linux-vmstat-remote/mm/vmstat.c @@ -883,7 +883,7 @@ static int refresh_cpu_vm_stats(void) } /* - * Fold the data for an offline cpu into the global array. + * Fold the data for a cpu into the global array. * There cannot be any access by the offline cpu and therefore * synchronization is simplified. */ @@ -904,8 +904,7 @@ void cpu_vm_stats_fold(int cpu) if (pzstats->vm_stat_diff[i]) { int v; - v = pzstats->vm_stat_diff[i]; - pzstats->vm_stat_diff[i] = 0; + v = xchg(&pzstats->vm_stat_diff[i], 0); atomic_long_add(v, &zone->vm_stat[i]); global_zone_diff[i] += v; } @@ -915,8 +914,7 @@ void cpu_vm_stats_fold(int cpu) if (pzstats->vm_numa_event[i]) { unsigned long v; - v = pzstats->vm_numa_event[i]; - pzstats->vm_numa_event[i] = 0; + v = xchg(&pzstats->vm_numa_event[i], 0); zone_numa_event_add(v, zone, i); } } @@ -932,8 +930,7 @@ void cpu_vm_stats_fold(int cpu) if (p->vm_node_stat_diff[i]) { int v; - v = p->vm_node_stat_diff[i]; - p->vm_node_stat_diff[i] = 0; + v = xchg(&p->vm_node_stat_diff[i], 0); atomic_long_add(v, &pgdat->vm_stat[i]); global_node_diff[i] += v; }