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 33DDEC7EE36 for ; Thu, 2 Mar 2023 14:48:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 277206B0074; Thu, 2 Mar 2023 09:48:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FEAC6B0075; Thu, 2 Mar 2023 09:48:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 079E76B0078; Thu, 2 Mar 2023 09:48:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id E25616B0074 for ; Thu, 2 Mar 2023 09:48:53 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 899F780724 for ; Thu, 2 Mar 2023 14:48:53 +0000 (UTC) X-FDA: 80524240146.23.4C1C842 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf24.hostedemail.com (Postfix) with ESMTP id B510818001D for ; Thu, 2 Mar 2023 14:48:51 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ObdMpX61; spf=pass (imf24.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=1677768531; 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=2ocr1MRMgM37lnhAgthxsVmxMsm7Y/8cuudEiaAKuwM=; b=rXwsqPrIcg962GOxeSf2dlUUVIExASKrin2MdSvLvca3HqTA/z83WK5LIgY1/YeqCHjqiF ki5J7OC0qup7peN2zHE+0WpwdGqKZKCRvQDm+w/3cjx6K/CkMiQNm6rU9C/Iu/D8JvGCrH 5e+FSHLE34GEtF5ppi/Eloj20jmRYQw= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ObdMpX61; spf=pass (imf24.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=1677768531; a=rsa-sha256; cv=none; b=vYYwO/QJ/owBe73ATAyps0lqYPr2TX8Gl6BZmfDvAOzsXXhzZ+CiCb95zCIbehPlhM4dnz P4LQkNAHHhCvYqnfk8+G1UNpMIznRFlfFBymUJZNoZACUlNr28rycO483KmzbRbO0YrJN2 3slFFjsyVD40JbItmggoQMU8gU7QcmY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1677768531; 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=2ocr1MRMgM37lnhAgthxsVmxMsm7Y/8cuudEiaAKuwM=; b=ObdMpX61L0HFOX4W4cSzAkpXuiMwBNYQt/EZxWuY7D9zzFiWCkjQn5MEwlm4cai0KSbSJL ZXoQozIJq7qQv0P8eBgwyJTNVG+YrmXfzHLq+yNBeLhxACrPUQaAGk4wvH3RxQKQ7Lzujo fZRJffYsZRLe3LGAXy8M0MWZTvPcJJw= 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-519-TZV8PsbCMI23Sb8WOOhCgQ-1; Thu, 02 Mar 2023 09:48:48 -0500 X-MC-Unique: TZV8PsbCMI23Sb8WOOhCgQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 64D9338173C8; Thu, 2 Mar 2023 14:48:47 +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 2B05E492C18; Thu, 2 Mar 2023 14:48:47 +0000 (UTC) Received: by tpad.localdomain (Postfix, from userid 1000) id 516A3403CFADF; Thu, 2 Mar 2023 11:47:35 -0300 (-03) Date: Thu, 2 Mar 2023 11:47:35 -0300 From: Marcelo Tosatti To: David Hildenbrand Cc: Christoph Lameter , Aaron Tomlin , Frederic Weisbecker , Andrew Morton , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2 08/11] mm/vmstat: switch counter modification to cmpxchg Message-ID: References: <20230209150150.380060673@redhat.com> <20230209153204.846239718@redhat.com> <3331790c-95a1-6ab9-2667-86aae3d28d7d@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3331790c-95a1-6ab9-2667-86aae3d28d7d@redhat.com> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B510818001D X-Rspam-User: X-Stat-Signature: zqjtaoe73dtjgbtyfp7z3y8oo1iy1izw X-HE-Tag: 1677768531-52136 X-HE-Meta: U2FsdGVkX1+d3IySdUHcchUpfWu7xAwPHrIlD1SCNOGxgRq0OUfEb4ECHPmZ6A880T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91KmczG3YPw2DvJx6Jslvuf1xhdcFxH7uoG8njwIXDYo/xp4vgQ== 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: On Thu, Mar 02, 2023 at 11:47:35AM +0100, David Hildenbrand wrote: > On 09.02.23 16:01, Marcelo Tosatti wrote: > > In preparation to switch vmstat shepherd to flush > > per-CPU counters remotely, switch all functions that > > modify the counters to use cmpxchg. > > > > To test the performance difference, a page allocator microbenchmark: > > https://github.com/netoptimizer/prototype-kernel/blob/master/kernel/mm/bench/page_bench01.c > > with loops=1000000 was used, on Intel Core i7-11850H @ 2.50GHz. > > > > For the single_page_alloc_free test, which does > > > > /** Loop to measure **/ > > for (i = 0; i < rec->loops; i++) { > > my_page = alloc_page(gfp_mask); > > if (unlikely(my_page == NULL)) > > return 0; > > __free_page(my_page); > > } > > > > Unit is cycles. > > > > Vanilla Patched Diff > > 159 165 3.7% > > > > 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 > > @@ -334,6 +334,188 @@ void set_pgdat_percpu_threshold(pg_data_ > > } > > } > > I wonder why we get a diff that is rather hard to review because it removes > all existing codes and replaces it by almost-identical code. Are you maybe > moving a bunch of code while modifying some tiny bits at the same time? Current code has functions defined like so: __mod_zone_page_state __mod_node_page_state __inc_zone_page_state __inc_node_page_state __dec_zone_page_state __dec_node_page_state #ifdef CONFIG_HAVE_CMPXCHG_LOCAL mod_zone_page_state inc_zone_page_state dec_zone_page_state mod_node_page_state inc_node_page_state dec_node_page_state #else mod_zone_page_state inc_zone_page_state dec_zone_page_state mod_node_page_state inc_node_page_state dec_node_page_state #endif What this patch is doing is to define the __ versions for the CONFIG_HAVE_CMPXCHG_LOCAL case to be their non-"__" counterparts. So it will be: #ifdef CONFIG_HAVE_CMPXCHG_LOCAL mod_zone_page_state inc_zone_page_state dec_zone_page_state mod_node_page_state inc_node_page_state dec_node_page_state __mod_zone_page_state (new function, calls mod_zone_page_state). __mod_node_page_state (new function, calls mod_node_page_state). __inc_zone_page_state __inc_node_page_state __dec_zone_page_state __dec_node_page_state #else __mod_zone_page_state (old, shared function for both CONFIG_HAVE_CMPXCHG_LOCAL and not) __mod_node_page_state __inc_zone_page_state __inc_node_page_state __dec_zone_page_state __dec_node_page_state mod_zone_page_state inc_zone_page_state dec_zone_page_state mod_node_page_state inc_node_page_state dec_node_page_state #endif Any suggestion on how to split this into multiple patchsets for easier reviewing? (can't think of anything obvious).