From patchwork Mon May 15 18:00:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13242019 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 D33A5C7EE24 for ; Mon, 15 May 2023 18:04:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 685D090000F; Mon, 15 May 2023 14:04:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 639CF90000D; Mon, 15 May 2023 14:04:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39EE390000F; Mon, 15 May 2023 14:04:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 23CEF90000D for ; Mon, 15 May 2023 14:04:03 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id D87D441432 for ; Mon, 15 May 2023 18:04:02 +0000 (UTC) X-FDA: 80793263124.13.F247982 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf08.hostedemail.com (Postfix) with ESMTP id EEE5F160043 for ; Mon, 15 May 2023 18:03:49 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="M/Drxb1/"; spf=pass (imf08.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.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=1684173830; 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=Hcv+7yXWUE6dz6IV3pdXnHOeNZqOsphpnY/hyL0+XpA=; b=mRGX8W22J+5SiPmWtg+dszZKzJ8bylXv47agQjPVPFeTLKtOJJaBatpB6r3btqdjiZ4ugV R3x/sWrvIzs+9Iuk9eNLZ07/DEzcNoeCMOiCp9PMd7QHLgPKKGyFrFgnspZnmal0Q894Rv hO0inrzBbLlpbivgZwsKuTYX4Gh8Pnc= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="M/Drxb1/"; spf=pass (imf08.hostedemail.com: domain of mtosatti@redhat.com designates 170.10.129.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=1684173830; a=rsa-sha256; cv=none; b=Oak/00cjbhxtf0fiwDdK5UpQkTAItiY/7bMMmCsqESFu/yWy3UfRQYZW7uv8uf3REa3TrO 0HKcO5CPEz5NTA3fI4B/9lfnnb1/J73tyih/mdrghgb5uvzCvhrBJYiAE5dvH8r1VZh4cB bSluq2fl6D+nz+Vzq+ORh2NAIow1WzA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684173829; 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=Hcv+7yXWUE6dz6IV3pdXnHOeNZqOsphpnY/hyL0+XpA=; b=M/Drxb1/aAle5djKgVVX8K2IpxERk6fQNT3pY0mOzN6FpOJh7IhSdUnTBlOvr/zlpOox8k MXqJ3vC9obHmcFjUetmEcBByC4YjaPWziWxWOCdDcFzOwg2W2E71ek3s2PMGWEGc34NCUD 15gjkLCKNymGOzLoxkc+g3lhQqLFYHw= 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-411-lHcv7IUkO2a5FK4nyxKaQw-1; Mon, 15 May 2023 14:03:43 -0400 X-MC-Unique: lHcv7IUkO2a5FK4nyxKaQw-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0080E88CC41; 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 C62E92166B26; Mon, 15 May 2023 18:03:42 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 7B6454133CFAA; Mon, 15 May 2023 15:02:17 -0300 (-03) Message-ID: <20230515180138.668066640@redhat.com> User-Agent: quilt/0.67 Date: Mon, 15 May 2023 15:00:25 -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 10/13] mm/vmstat: use xchg in cpu_vm_stats_fold References: <20230515180015.016409657@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Stat-Signature: e7meun9e3d8sof4gpre1pqu7aqryh93x X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: EEE5F160043 X-Rspam-User: X-HE-Tag: 1684173829-180301 X-HE-Meta: U2FsdGVkX1/2yee71Mm95++SqKW7Wk8Aw4dsZq/CH7qiqzq2QBockc5yW5xh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jq8NusmZW79x65JpSQLgIPv/OmFfP5DX7xWOthulW00P6vp9luuh+4E10iQA6ELiAKpisJPwvmEbtogDNwLBPvRXa9yRntg1qrZLxdQX+soihRy28nzySky7h 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 @@ -924,7 +924,7 @@ static int refresh_cpu_vm_stats(bool do_ } /* - * 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. */ @@ -945,8 +945,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; } @@ -956,8 +955,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); } } @@ -973,8 +971,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; }