Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp416959iob; Fri, 13 May 2022 04:43:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy8lOr6Dv+PAaQ+uU7xURYZDo3PAwuGWRJ78XTHS8vWlCmgSpceRxK7XPoVuICkdb+MhA8G X-Received: by 2002:a17:906:dc8a:b0:6f9:13e9:4c87 with SMTP id cs10-20020a170906dc8a00b006f913e94c87mr3781631ejc.729.1652442208114; Fri, 13 May 2022 04:43:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652442208; cv=none; d=google.com; s=arc-20160816; b=xIWUy2rh4UBoeU9YPOyIPZfIT5ge2T2cdN5rQQ3wG8UK63FrPBnoiV23JF5Hqf3yvo PE8H4o5LhQaLgCAb4lwNSqwts5wlSpwix/glTT71OXt4VbAvejo+YvMjXXmE7q9QuhZi P52klaDUn0N9/9YwqbLFFUhf0W6gm1nkEO8IGweBxMtLk5tUAI701gYG2UTbQUJ903tQ fJC/4aIB464QZPWmqJ0bfnQQLGyng3w4tQ4iT6tGauJbxyta2X7dVEHi9le0ipKq+qxF NgqkIydR6r3P/BPA9gUdW4zu0hO05kqi5lFnj/gvm+JbJ9UuHQOt6gSxmakCuUktjPgJ acTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=e8hLZ2k76sQ/lAj89TuSmh5mE/pHaIG/F6uVRb9/hHo=; b=YUN7uB1ZObF5+QPVDSkOpgaoZOcH8uscemFnisYfN/Krwuu4P4JAsZE6nndKRuBHwd wyk5yKiSbOGMj0K43UrMycmCFnuoOgPAsmmq8/46HxRvt+qNAL0Z/oe9qZVLs2OLcOQR yi6fvcjKkb6j4wZGDvygpgyk6ymh/zRhaRJE1jYr65lDncT9ALDVj/FzxTCgiyVdtHNE OXfe/WB8vTjoJSnyElFj6iTUN28WtD+/GUfB0VYyE90dZmRON4rhQwIjnC2HUUguy916 IQXbPFzD+7qynh0ilpsnh/QIZFNJszVX0sseH+K7etclITiuWyIZ6ztsJv/kAhnB3kZY Vnug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=kCp0SYUU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u16-20020a170906951000b006f392f11feasi1749072ejx.20.2022.05.13.04.43.01; Fri, 13 May 2022 04:43:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=kCp0SYUU; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357463AbiELSGl (ORCPT + 99 others); Thu, 12 May 2022 14:06:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243594AbiELSGi (ORCPT ); Thu, 12 May 2022 14:06:38 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D818A4A3C9 for ; Thu, 12 May 2022 11:06:36 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 62B61615FA for ; Thu, 12 May 2022 18:06:36 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 195E3C385B8; Thu, 12 May 2022 18:06:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1652378795; bh=Z83eG3p+kTpRWNVo3X1S7ImubJc9khpP2Bx1OiOMN18=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=kCp0SYUU/LJxTqwunAMws1EkGrUVJNlkWLPl0A0JxAUdjPYvT0yQT//j42UwOeYZd +rVQQDwLUPSdFMZOGa01Mj6vqlu7jYJws/HW2fxII5HY5Ubx18bp9sh5BfVjB3Xxzh WDBPAGEYTnCbxtVV03WBDLF8G5D3NVaiGQGzO8Jc= Date: Thu, 12 May 2022 11:06:34 -0700 From: Andrew Morton To: Linus Torvalds Cc: Aaron Lu , "ying.huang@intel.com" , Waiman Long , Peter Zijlstra , Will Deacon , Mel Gorman , kernel test robot , Vlastimil Babka , Dave Hansen , Jesper Dangaard Brouer , Michal Hocko , LKML , lkp@lists.01.org, kernel test robot , Feng Tang , Zhengjun Xing , fengwei.yin@intel.com, linux-mm@kvack.org Subject: Re: [mm/page_alloc] f26b3fa046: netperf.Throughput_Mbps -18.0% regression Message-Id: <20220512110634.712057e4663ecc5f697bf185@linux-foundation.org> In-Reply-To: References: <37dac785a08e3a341bf05d9ee35f19718ce83d26.camel@intel.com> <41c08a5371957acac5310a2e608b2e42bd231558.camel@intel.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 12 May 2022 10:42:09 -0700 Linus Torvalds wrote: > On Thu, May 12, 2022 at 5:46 AM Aaron Lu wrote: > > > > When nr_process=16, zone lock contention increased about 21% from 6% to > > 27%, performance dropped 17.8%, overall lock contention increased 14.3%: > > So the contention issue seems real and nasty, and while the queued > locks may have helped a bit, I don't think they ended up making a > *huge* change: the queued locks help make sure the lock itself doesn't > bounce all over the place, but clearly if the lock holder writes close > to the lock, it will still bounce with at least *one* lock waiter. > > And having looked at the qspinlock code, I have to agree with Waiman > and PeterZ that I don't think the locking code can reasonably eb > changed - I'm sure this particular case could be improved, but the > downsides for other cases would be quite large enough to make that a > bad idea. > > So I think the issue is that > > (a) that zone lock is too hot. > > (b) given lock contention, the fields that get written to under the > lock are too close to the lock > > Now, the optimal fix would of course be to just fix the lock so that > it isn't so hot. But assuming that's not possible, just looking at the > definition of that 'struct zone', I do have to say that the > ZONE_PADDING fields seem to have bit-rotted over the years. > > The whole and only reason for them would be to avoid the cache > bouncing, but commit 6168d0da2b47 ("mm/lru: replace pgdat lru_lock > with lruvec lock") actively undid that for the 'lru_lock' case, and > way back when commit a368ab67aa55 ("mm: move zone lock to a different > cache line than order-0 free page lists") tried to make it true for > the 'lock' vs free_area[] cases, but did it without actually using the > ZONE_PADDING thing, but by moving things around, and not really > *guaranteeing* that 'lock' was in a different cacheline, but really > just making 'free_area[]' aligned, but still potentially in the same > cache-line as 'lock' (so now the lower-order 'free_area[]' entries are > not sharing a cache-line, but the higher-order 'free_area[]' ones > probably are). > > So I get the feeling that those 'ZONE_PADDING' things are a bit random > and not really effective. > > In a perfect world, somebody would fix the locking to just not have as > much contention. But assuming that isn't an option, maybe somebody > should just look at that 'struct zone' layout a bit more. (hopefully adds linux-mm to cc)