From patchwork Tue Mar 14 18:59:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13174925 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 17640C74A44 for ; Tue, 14 Mar 2023 19:01:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3B758E0005; Tue, 14 Mar 2023 15:01:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C72B38E0001; Tue, 14 Mar 2023 15:01:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3A3F8E0003; Tue, 14 Mar 2023 15:01:12 -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 A19E88E0001 for ; Tue, 14 Mar 2023 15:01:12 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 74D49AB325 for ; Tue, 14 Mar 2023 19:01:12 +0000 (UTC) X-FDA: 80568421584.19.12078A5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf02.hostedemail.com (Postfix) with ESMTP id 5DA9280025 for ; Tue, 14 Mar 2023 19:01:10 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="K/+c7SNo"; spf=pass (imf02.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=1678820470; a=rsa-sha256; cv=none; b=JIeu1NpP53MyXn3s3jA6mPOHFqLkkbmmr4CS7AtHiKlll/HrYDqUjwfjnjmag5AT2+Lt6R Ps01gyJd6mbWnY+5NGyL4L3NTCgCTVHsUZPr1IDHgWC6z4MMylb+JTOSIjtwJvTbt2kRbz F6PCDCKFiNLw3rA4qEAy9PhwpLM6PuQ= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="K/+c7SNo"; spf=pass (imf02.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=1678820470; 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=/KQqYUQDwTZyYbpRZbwn7x1mgss03C//4Fvg72sL2vY=; b=R9lAmuvonPE3PMaCoibwPhbrsC8LN/QzQXcNdR9Diqfp/O4wtMoKkXRcPkItyrY9y6XdXL AXnpFeUDyiFhOXSuCb9iwi7ouJ2zzbf6Fp4TygoB5tYinEMT28w9YG5AkCrGGmKCBDvROC 3CKMxB1AOTMT7J8U7JxQQEVv9g0bxZk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678820469; 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=/KQqYUQDwTZyYbpRZbwn7x1mgss03C//4Fvg72sL2vY=; b=K/+c7SNoXt6BqJh7A8DAgfMCsqZSI0eX+n6Woc8u9ohaWgQw45S06o3JBn8nDasoN9K0TN Wn/MVEVZUpAd9ZiOw0KkSPS7fxkHDALLZ2IHI+LtFWQ3AYuWLIs5bMGVsxqVK+WJ+DD+C3 A7Oo6IAZzGf8891wdt1efqJ2UNJAnNA= 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-416-vzkJw1CyPTS8_TahwjoFcg-1; Tue, 14 Mar 2023 15:01:06 -0400 X-MC-Unique: vzkJw1CyPTS8_TahwjoFcg-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 136261024D28; Tue, 14 Mar 2023 19:01:05 +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 DB2631410F1B; Tue, 14 Mar 2023 19:01:04 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 7585B4039C293; Tue, 14 Mar 2023 16:00:44 -0300 (-03) Message-ID: <20230314185951.754032715@redhat.com> User-Agent: quilt/0.67 Date: Tue, 14 Mar 2023 15:59:23 -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 09/12] mm/vmstat: use xchg in cpu_vm_stats_fold References: <20230314185914.836510860@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-Rspam-User: X-Rspamd-Queue-Id: 5DA9280025 X-Rspamd-Server: rspam01 X-Stat-Signature: h1ktyx9qx7qkqrg1q3ncqo1y1wm7qbij X-HE-Tag: 1678820470-610940 X-HE-Meta: U2FsdGVkX1/Lm44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Dx/yMBpv99LIoEhI9s1YmzlaMp7GgJNiVJQgjLRqfWKbFqlCszXgXEhHilBJT2ufMj8Hc0P31xqmyWQEY8lnBzQ7p+UoYFubK14mp/8BWSwfUHC8qxzQscyBQ7uOZqshRYM45PrWOLkZE62/OAagYQO3IlOjoXOI5Iv1jPucOrNg0G6k6drzfgf9Nw== 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; }