From mboxrd@z Thu Jan 1 00:00:00 1970 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 5F117C77B7A for ; Tue, 16 May 2023 18:05:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB84B900003; Tue, 16 May 2023 14:05:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D4108900002; Tue, 16 May 2023 14:05:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBCC7900003; Tue, 16 May 2023 14:05:18 -0400 (EDT) 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 A8DE4900002 for ; Tue, 16 May 2023 14:05:18 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 6A0EF1C70D6 for ; Tue, 16 May 2023 18:05:18 +0000 (UTC) X-FDA: 80796895116.01.62154BD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf22.hostedemail.com (Postfix) with ESMTP id CF0F6C0067 for ; Tue, 16 May 2023 18:05:08 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Fw7XGOVJ; spf=pass (imf22.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=1684260309; 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:in-reply-to:references:references:dkim-signature; bh=Y5EOypxgbZDRGvVwT5KvydBJmWedm0p4xvCj98nOYvY=; b=qevsRBSjxBMxXpK8/CuMI8rygERhYDpVOtOSe0DBATmVMaktqqTioUDLtY/jCPEq+rf2Au 2XRNJT4MmuGkpI03A67PM6r0JjuWtFaKGpJIV3VFV7yZf9sFFvqMRU/HfSCPt4qMOWbMmD Ox6rjWW36mTP6XF+rtGpAyAdR7lRPEM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684260309; a=rsa-sha256; cv=none; b=AnVQSensSPdw5/Xx7uF+9tRMz4YcVIjBwPGl4YLdSvlBjCS+qYsHoKFtC8nT1E1nEqJWcq HACD1XUTvhhCvfSJqANT9Myu0+Wh5larY7NVWV+xczhjPHIiRxC+3UeCL1kPG3zD8OKc6z qGXZ/SrTHlNuyUlDsrQ0wMf7oqdkF5g= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Fw7XGOVJ; spf=pass (imf22.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684260308; 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: in-reply-to:in-reply-to:references:references; bh=Y5EOypxgbZDRGvVwT5KvydBJmWedm0p4xvCj98nOYvY=; b=Fw7XGOVJuaW43mH0qAchW/NqSx0s5sGzlzfU+Gxogc3rj2CrmYzEjfWtmc7rQleHChZ1Ml WYbs0dgsAdPMizdBrZh9Gpx2iv/kHiqT6muz0yCjlmPYb35e99MybmSo1zxmbNmY0mNT9k yUF1xh9w4bn0CSydvyDkWgBJJziU0xM= 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-450-C0cacgM5PRuPUxecaQIZTw-1; Tue, 16 May 2023 14:05:02 -0400 X-MC-Unique: C0cacgM5PRuPUxecaQIZTw-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 080E3101A557; Tue, 16 May 2023 18:05:01 +0000 (UTC) Received: from tpad.localdomain (ovpn-112-3.gru2.redhat.com [10.97.112.3]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B1C435453; Tue, 16 May 2023 18:05:00 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 53BA84013A22A; Tue, 16 May 2023 15:02:21 -0300 (-03) Date: Tue, 16 May 2023 15:02:21 -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 Subject: Re: [PATCH v8 00/13] fold per-CPU vmstats remotely Message-ID: References: <20230515180015.016409657@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Stat-Signature: z7q93m1jspp7ggkkk9hh9wkpxkcf6ic6 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: CF0F6C0067 X-Rspam-User: X-HE-Tag: 1684260308-620225 X-HE-Meta: U2FsdGVkX18i7G5DJBRJUmh2JxGkygFV0Wh/8vE1gGBBGdLbRyP3yvTT9TErOdRIyqypgHk6P2fVRDNe2nl2xKxb1Prh9s/5zKxa9n2onr4fQOPqqdJzwmwJI4KAox/zMTh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ner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Hi Christoph, On Tue, May 16, 2023 at 10:09:02AM +0200, Christoph Lameter wrote: > The patchset still modifies the semantics of this_cpu operations semantics > replacing the lockless RMV operations with locked ones. It does that to follow the pre-existing kernel convention: function-name LOCK prefix cmpxchg YES cmpxchg_local NO So the patchset introduces: function-name LOCK prefix this_cpu_cmpxchg YES this_cpu_cmpxchg_local NO > One of the > rationales for the use this_cpu operations is their efficiency since > locked RMV atomics are avoided. And there is the freedom to choose between this_cpu_cmpxchg and this_cpu_cmpxchg_local (depending on intended usage). > This patchset destroys that functionality. Patch 6 is Subject: [PATCH v8 06/13] add this_cpu_cmpxchg_local and asm-generic definitions Which adds this_cpu_cmpxchg_local Patch 7 converts all other this_cmpxchg users (except the vmstat ones) [PATCH v8 07/13] convert this_cpu_cmpxchg users to this_cpu_cmpxchg_local So the non-LOCK'ed behaviour is maintained for existing users. > If you want locked RMV semantics then use them through cmpxchg() and > friends. Do not modify this_cpu operations by changing the implementation > in the arch code. But then it would be necessary to disable preemption here: static inline void mod_zone_state(struct zone *zone, enum zone_stat_item item, long delta, int overstep_mode) { struct per_cpu_zonestat __percpu *pcp = zone->per_cpu_zonestats; s32 __percpu *p = pcp->vm_stat_diff + item; long o, n, t, z; do { z = 0; /* overflow to zone counters */ /* * The fetching of the stat_threshold is racy. We may apply * a counter threshold to the wrong the cpu if we get * rescheduled while executing here. However, the next * counter update will apply the threshold again and * therefore bring the counter under the threshold again. * * Most of the time the thresholds are the same anyways * for all cpus in a zone. */ t = this_cpu_read(pcp->stat_threshold); o = this_cpu_read(*p); n = delta + o; if (abs(n) > t) { int os = overstep_mode * (t >> 1); /* Overflow must be added to zone counters */ z = n + os; n = -os; } } while (this_cpu_cmpxchg(*p, o, n) != o); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ if (z) zone_page_state_add(z, zone, item); } Earlier you objected to disabling preemption on this codepath (which is what led to this patchset in the first place): "Using preemption is a way to make this work correctly. However, doing so would sacrifice the performance, low impact and the scalability of the vm counters." So it seems a locked, this_cpu function which does lock cmxpchg is desired. Perhaps you disagree with the this_cpu_cmpxchg_local/this_cpu_cmpxchg naming?