From patchwork Mon Mar 20 18:03:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 13181686 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 07D4DC76195 for ; Mon, 20 Mar 2023 18:12:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D33A6B0078; Mon, 20 Mar 2023 14:12:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 882C66B007B; Mon, 20 Mar 2023 14:12:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74B176B007D; Mon, 20 Mar 2023 14:12:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 65B686B0078 for ; Mon, 20 Mar 2023 14:12:11 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 34CFA1C5B94 for ; Mon, 20 Mar 2023 18:12:11 +0000 (UTC) X-FDA: 80590070862.07.9A3885F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf15.hostedemail.com (Postfix) with ESMTP id 70027A000B for ; Mon, 20 Mar 2023 18:12:08 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Mp3A37UD; spf=pass (imf15.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=1679335928; 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=K/gJ02M07gMt3fWqZLDBgUDS3grs+h+PjLmwiu9lRXG/gGchbX6TExMgRVjb0IdZIKoxj+ sAf8WiN0CGlmrGyExINvCoSPNOXbnPQJrXZV98rHRT3yhh8XCaH4ZKQl7y4JbbxJIk4ojD IFsehHYxBr9Ycp/xG1EMg2rbEyzcxnY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Mp3A37UD; spf=pass (imf15.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=1679335928; a=rsa-sha256; cv=none; b=I9PHzJYyMGT/lhpEs3vOFZXqyamTsfpdWxBtU6iBSyAJvPZN+DL5GHmpHSL5ppoOd3zado VTeKB59Z4UcT+xvnSwb3xYDhsxHwsRQMZek2fqo2OhAEMZW1mA2uiIhskK2rN+xm+aaahG OzC0b43V/DDW0nAW1OFrDDJBRa9rV74= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1679335927; 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=Mp3A37UDIH34B5E06Vba5VUikhPvTao2jlZ0bB6NPYtrDmF8We9SPTBi+ku3mTHJedIABL 58hAEOofRS3YJACqYi8oLZZKJXD6jQBI+5lO0D8VFUXzBu8Qv7oc/MN9L53jAVH6icfXIm Im2pcqo5gxBdw2e+d3AKg3v6v02mKdA= 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-607-5Z2d1MOjMb2V2UyjiOPjmg-1; Mon, 20 Mar 2023 14:12:04 -0400 X-MC-Unique: 5Z2d1MOjMb2V2UyjiOPjmg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7273338173CB; Mon, 20 Mar 2023 18:12:03 +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 2094F18EC2; Mon, 20 Mar 2023 18:12:03 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 0360D403BCD84; Mon, 20 Mar 2023 15:08:03 -0300 (-03) Message-ID: <20230320180745.783045641@redhat.com> User-Agent: quilt/0.67 Date: Mon, 20 Mar 2023 15:03:42 -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 v7 10/13] mm/vmstat: use xchg in cpu_vm_stats_fold References: <20230320180332.102837832@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 70027A000B X-Rspam-User: X-Stat-Signature: o441j1nofjwpbg1hw7xn5xouegjxo48t X-HE-Tag: 1679335928-227600 X-HE-Meta: U2FsdGVkX18OP3hFL1BgGpl+kRyV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4J+a+l14mSgAyzrFo03EJ0rMb4L0Gld4IhbpE4YoaSzXJVnPABxE5Gy6kPowD7eXowJSLddpuTCkPh1YPNyc8fvEsjc4AMWLvQpRtNIT/rHpKUL0rioxvkooLqMD0vUr+hdSDoM5XfkXxS7vS0RPYmow+u8ezDKLTgd37ej4aJmlmQg== 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; }