Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp3817838rdb; Thu, 14 Sep 2023 03:46:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFrRVIfaIbWV1gLpHlGZoU2me8xaRCgu/Mv+OTNecz4zSdmA4wUsiFesMkFDsmQGsShY17h X-Received: by 2002:a17:902:ead2:b0:1c3:39f8:3e67 with SMTP id p18-20020a170902ead200b001c339f83e67mr5190982pld.20.1694688410708; Thu, 14 Sep 2023 03:46:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694688410; cv=none; d=google.com; s=arc-20160816; b=Ba2GoNiy8eyF11OxUKZ10jVL6eWUyglY+wv2hyfdEsCfLseQ+v8Qr4U+nTj0UCwsUT UHMgf7k32CtudQP4GLNyEZe+D2Obx0Zm2JEUAdYf/R5m46nZY45eM7gZRZBO8JFyevTy IjcwQv/jQ8p3NbVaNiNugCs+9UWxSfTOdxWh3PCEA44A7Bn6MnclOrgLaLCDvNUKbpOV FTwRLCE5m+bpRmbUwk5kUDwH4Y/h2HUXlC+PGAkgUbW9FwSOIKkP9A909V9WkkKVUSDk r33Jx7afhbbZMYYl8haIYMHQ3K9da7lGyiRPr3lBxHhtoBGYJnmZLad1KVU/CzVFx8yR OpUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=5zjHyRLlpcTdOKpMLLgT/GGfWt1NR/46qOt7w6B6FaM=; fh=P2xRvT/3gU4jeRPimgVadHxT1tx11QhdMtS7UZmJd28=; b=x7TwjGEt9lajzU1pL8CwoCTqiBpaOa6aWimPeJAt7/v+ymTveBto1zXGAMfFB/I4ks HCGyptqb3rLm9iRWj/VHxkjN752+t5Mc3r82Bfs4+jPaPJR0isWwUVk9Unj5tmgYKVlW MeReCFQhVlBgRMDckqQFNWaVvSbi2lFCBt6WnnQ6LQMJOnUQivrSsi74w13IhmroYopX Kal8E/pHotjD2iBUZZsF1qGYMYmsI6iaOdyqIN007v1I9qzem5SQHFSCB1Q1OJCWXwvf k72M0iTyLaxJFPbidoECJ5XcQ1lSw1oUqWyaCQsWaI8K3kTjbPRXoro+qJuC1mWTA/MB oyQw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id lc15-20020a170902fa8f00b001b8c47563e7si1354099plb.28.2023.09.14.03.46.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Sep 2023 03:46:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id BEBB880B19B0; Thu, 14 Sep 2023 02:56:35 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237690AbjINJ4b (ORCPT + 99 others); Thu, 14 Sep 2023 05:56:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237898AbjINJ4V (ORCPT ); Thu, 14 Sep 2023 05:56:21 -0400 Received: from outbound-smtp16.blacknight.com (outbound-smtp16.blacknight.com [46.22.139.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1003D83 for ; Thu, 14 Sep 2023 02:56:16 -0700 (PDT) Received: from mail.blacknight.com (pemlinmail06.blacknight.ie [81.17.255.152]) by outbound-smtp16.blacknight.com (Postfix) with ESMTPS id 25BDD1C3EE3 for ; Thu, 14 Sep 2023 10:56:15 +0100 (IST) Received: (qmail 3257 invoked from network); 14 Sep 2023 09:56:14 -0000 Received: from unknown (HELO techsingularity.net) (mgorman@techsingularity.net@[84.203.197.19]) by 81.17.254.9 with ESMTPSA (AES256-SHA encrypted, authenticated); 14 Sep 2023 09:56:14 -0000 Date: Thu, 14 Sep 2023 10:56:08 +0100 From: Mel Gorman To: Johannes Weiner Cc: Andrew Morton , Vlastimil Babka , Miaohe Lin , Kefeng Wang , Zi Yan , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] mm: page_alloc: remove pcppage migratetype caching Message-ID: <20230914095608.xswhhoz2rsvbe5zu@techsingularity.net> References: <20230911195023.247694-1-hannes@cmpxchg.org> <20230911195023.247694-2-hannes@cmpxchg.org> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: <20230911195023.247694-2-hannes@cmpxchg.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 14 Sep 2023 02:56:35 -0700 (PDT) X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email On Mon, Sep 11, 2023 at 03:41:42PM -0400, Johannes Weiner wrote: > The idea behind the cache is to save get_pageblock_migratetype() > lookups during bulk freeing. A microbenchmark suggests this isn't > helping, though. The pcp migratetype can get stale, which means that > bulk freeing has an extra branch to check if the pageblock was > isolated while on the pcp. > > While the variance overlaps, the cache write and the branch seem to > make this a net negative. The following test allocates and frees > batches of 10,000 pages (~3x the pcp high marks to trigger flushing): > > Before: > 8,668.48 msec task-clock # 99.735 CPUs utilized ( +- 2.90% ) > 19 context-switches # 4.341 /sec ( +- 3.24% ) > 0 cpu-migrations # 0.000 /sec > 17,440 page-faults # 3.984 K/sec ( +- 2.90% ) > 41,758,692,473 cycles # 9.541 GHz ( +- 2.90% ) > 126,201,294,231 instructions # 5.98 insn per cycle ( +- 2.90% ) > 25,348,098,335 branches # 5.791 G/sec ( +- 2.90% ) > 33,436,921 branch-misses # 0.26% of all branches ( +- 2.90% ) > > 0.0869148 +- 0.0000302 seconds time elapsed ( +- 0.03% ) > > After: > 8,444.81 msec task-clock # 99.726 CPUs utilized ( +- 2.90% ) > 22 context-switches # 5.160 /sec ( +- 3.23% ) > 0 cpu-migrations # 0.000 /sec > 17,443 page-faults # 4.091 K/sec ( +- 2.90% ) > 40,616,738,355 cycles # 9.527 GHz ( +- 2.90% ) > 126,383,351,792 instructions # 6.16 insn per cycle ( +- 2.90% ) > 25,224,985,153 branches # 5.917 G/sec ( +- 2.90% ) > 32,236,793 branch-misses # 0.25% of all branches ( +- 2.90% ) > > 0.0846799 +- 0.0000412 seconds time elapsed ( +- 0.05% ) > > A side effect is that this also ensures that pages whose pageblock > gets stolen while on the pcplist end up on the right freelist and we > don't perform potentially type-incompatible buddy merges (or skip > merges when we shouldn't), whis is likely beneficial to long-term > fragmentation management, although the effects would be harder to > measure. Settle for simpler and faster code as justification here. > > Signed-off-by: Johannes Weiner I've no specific objection and other minor corrections have already been suggested. I don't recall specifically but I think get_pageblock_migratetype might have been called redundantly once upon a time when there were concerns about page allocator overhead for high speed network. Now that there is bulk allocation and the flow has changed significantly, it's feasible to simply avoid calling get_pageblock_migratetype unnecessarily. Acked-by: Mel Gorman -- Mel Gorman SUSE Labs