From patchwork Sun Mar 5 13:37:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13160151 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 5E2E8C61DA4 for ; Sun, 5 Mar 2023 13:42:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB2FB6B0081; Sun, 5 Mar 2023 08:41:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B19566B0080; Sun, 5 Mar 2023 08:41:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5F2966B0081; Sun, 5 Mar 2023 08:41:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 2C3006B0080 for ; Sun, 5 Mar 2023 08:41:52 -0500 (EST) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 06CBA40A76 for ; Sun, 5 Mar 2023 13:41:52 +0000 (UTC) X-FDA: 80534957664.29.EAF37BA Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 4849F40012 for ; Sun, 5 Mar 2023 13:41:50 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jFizVWPG; spf=pass (imf07.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=1678023710; 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=jB4HjHlgiBdXSmS/ZICw/DYiAv3k/YOe6YUKnfmKEpUSBO1nLkMiwgA4YysReKp/+e7pEB pCJ4zwIQEkvFk+EiWyHEVpL/FobHKrpk/lsmxNu7BPyKU9LYtGIumaUv8pnYBQgFjYiUhM BoVt11wwDGaBNNcYvtvEmLVnjleaJl8= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=jFizVWPG; spf=pass (imf07.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=1678023710; a=rsa-sha256; cv=none; b=kqI+Ok1o9ap4tRdjGbz+bdSAYtAld+DjIw9/ZI7et2BzRxiv0ypqOLPGrxN04zKNk2O9Ka MBPMrT1plbqgv+eGAjoTDZMDkV6GM18wSgF2vxqkGLETbm60MwW2kyqwP/91rF3Q7hHppn IECr4KN0WHKRrMjo8gj/AHf1bIye63o= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678023709; 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=jFizVWPGjLl8vvfZmpdf4fOaS5BoHtHMGqlis/eiRW8Y1bJ3979mTgzvG+2BdWxdxeDYeY LUfVmmobSEG9snyro/+uewPTNPoVrcPRcpNndjCRhKt+Bm4fWeOfYpEddtHiAkPRZFcuYt oMikB2ZFJDXScjdofHv6ZrPufmIOyao= 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-83-LrdFy_6IOgSylGfx69LC-A-1; Sun, 05 Mar 2023 08:41:45 -0500 X-MC-Unique: LrdFy_6IOgSylGfx69LC-A-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 A9D8C29AA39A; Sun, 5 Mar 2023 13:41:44 +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 7B943400F8FA; Sun, 5 Mar 2023 13:41:44 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 3EE58401A193B; Sun, 5 Mar 2023 10:41:23 -0300 (-03) Message-ID: <20230305134053.663216906@redhat.com> User-Agent: quilt/0.67 Date: Sun, 05 Mar 2023 10:37:07 -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 v4 10/12] mm/vmstat: use xchg in cpu_vm_stats_fold References: <20230305133657.255737580@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Rspamd-Queue-Id: 4849F40012 X-Stat-Signature: zhp1xfrgh6wjuzgg417joouaatf1g43r X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1678023710-184842 X-HE-Meta: U2FsdGVkX18oVMb+MlufIEit6S9aHW9LPIaWv5kbohLFfSxUU++IHa2RaZyz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AyirjsPzPvkLh4Si/bQXyGc7Ej3Rk1jwKAmiz4qjlVVGyScdDGOKsDzcz0I4MzNqMjFVVTuUF1dN6pY7ixFJiZys4Kf6TV8Vh4DSNjZ0s= 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; }