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 X-Spam-Level: X-Spam-Status: No, score=-2.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA6F7C433DB for ; Wed, 17 Mar 2021 22:23:07 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1F91564F20 for ; Wed, 17 Mar 2021 22:23:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1F91564F20 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 5E4FE6B0070; Wed, 17 Mar 2021 18:23:06 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 595796B0071; Wed, 17 Mar 2021 18:23:06 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45CC66B0072; Wed, 17 Mar 2021 18:23:06 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0192.hostedemail.com [216.40.44.192]) by kanga.kvack.org (Postfix) with ESMTP id 28B236B0070 for ; Wed, 17 Mar 2021 18:23:06 -0400 (EDT) Received: from smtpin39.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id CF01618039020 for ; Wed, 17 Mar 2021 22:23:05 +0000 (UTC) X-FDA: 77930792730.39.EF6DE27 Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) by imf18.hostedemail.com (Postfix) with ESMTP id 5674A2000248 for ; Wed, 17 Mar 2021 22:23:05 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id v2so136433pgk.11 for ; Wed, 17 Mar 2021 15:23:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:subject:to:cc:references:in-reply-to:mime-version :message-id:content-transfer-encoding; bh=RZEKJdaq0V9wtqqXxPUbM9eFMZIGKO+oIBHl3RZ/clg=; b=RZnFlLbj+h0fD+khd1c1DwBlD8SwMkyXlQ48JxicRxVZphgGnat81u/asaG7NN10dD VONZG+h2F/5BK5McnwfWB39N8MXytyVl9Swt8PMDzHfvzbrPzTeq6NrqdZWAbjIKvake v60ZCp21j4SiTwATeUwn5URW/O9XLOlJ2AzmkBAk5XKirHGDimxQXhgRlwqcI1jtaFzI 14wrwBqlZUApyZ0armmOReq/luJaxx5hnM+yIMms3TCTJh/REW0lVZds/Zksg0+sytXX IJriOR+QnUOeRH0GWdxvIwSvho0fAfOKjEkn90nof8exkhNKvpZmt+I2vY7+xu2sqnTM z5eA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:subject:to:cc:references:in-reply-to :mime-version:message-id:content-transfer-encoding; bh=RZEKJdaq0V9wtqqXxPUbM9eFMZIGKO+oIBHl3RZ/clg=; b=uBkn9R5btTWLKZFEDqC+9+olLbn+KJQFtzBTCK1O6MTuUVoi+3gzhrfxO6VlpMndsn Bv70LMku9ebLYg9YBQEzTWs/G3Pst44ZbssAZyXGJJkm8bLXP0Sa1qz1v1hWk6zr35e6 WfN0M5GGlcirGRyBeakhykrgqeF33jTDhYazWNWowHS93sIIR16p5ooK+ML9q+w7u10O 1VvWJ0aUOs6SxUlBBbgEiQSJII/7CUo/rTOgnxqc6Ki8f4g0JfK8VX6dey/4J0x3VKHn bsUBYnbx0iYcLxP/MYy4PAvyAWbpFv63xJpgXqGIPRat3FG8/WFyQ8LLH0nS6VwHRXhG 6j4g== X-Gm-Message-State: AOAM5307EmQO8JYpsOdUWzUyLpXR6c/wdkP7LVPe2b7ZZMwX8Kt5kBY8 voGU6QWDkajlbn1TJHdTlj4= X-Google-Smtp-Source: ABdhPJxpz/ExboVKk5U/bOB6GZxeEG5n2ISzVKfpLZD5yaSSNW6X+02HyAOnx2dxAtETBVgc7RcQag== X-Received: by 2002:a63:4761:: with SMTP id w33mr4395880pgk.118.1616019784274; Wed, 17 Mar 2021 15:23:04 -0700 (PDT) Received: from localhost ([58.84.78.96]) by smtp.gmail.com with ESMTPSA id v7sm105585pfv.93.2021.03.17.15.23.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Mar 2021 15:23:03 -0700 (PDT) Date: Thu, 18 Mar 2021 08:22:57 +1000 From: Nicholas Piggin Subject: Re: [PATCH v2] Increase page and bit waitqueue hash size To: Linus Torvalds Cc: Andrew Morton , Anton Blanchard , Linux Kernel Mailing List , Linux-MM , Rasmus Villemoes , Ingo Molnar References: <20210317075427.587806-1-npiggin@gmail.com> <89cb49c0-2736-dd4c-f401-4b88c22cc11f@rasmusvillemoes.dk> <1615977781.fijkhk7ep5.astroid@bobo.none> In-Reply-To: MIME-Version: 1.0 Message-Id: <1616017462.cmzed2nj60.astroid@bobo.none> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Stat-Signature: gfzgbubei9a3pu64hcqcrh5r97w9okt6 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 5674A2000248 Received-SPF: none (gmail.com>: No applicable sender policy available) receiver=imf18; identity=mailfrom; envelope-from=""; helo=mail-pg1-f178.google.com; client-ip=209.85.215.178 X-HE-DKIM-Result: pass/pass X-HE-Tag: 1616019785-89148 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: Excerpts from Linus Torvalds's message of March 18, 2021 5:26 am: > On Wed, Mar 17, 2021 at 3:44 AM Nicholas Piggin wrote= : >> >> Argh, because I didn't test small. Sorry I had the BASE_SMALL setting in >> another patch and thought it would be a good idea to mash them together. >> In hindsight probably not even if it did build. >=20 > I was going to complain about that code in general. >=20 > First complaining about the hash being small, and then adding a config > option to make it ridiculously much *smaller* seemed wrong to begin > with, and didn't make any sense. >=20 > So no, please don't smash together. Fair point, fixed. >=20 > In fact, I'd like to see this split up, and with more numbers: >=20 > - separate out the bit_waitqueue thing that is almost certainly not > remotely as critical (and maybe not needed at all) >=20 > - show the profile number _after_ the patch(es) Might take some time to get a system and run tests. We actually had=20 difficulty recreating it before this patch too, so it's kind of hard to say _that_ was the exact case that previously ran badly and is now fixed. We thought just the statistical nature of collisions and page / lock contention made things occasionally line up and tank. > - explain why you picked the random scaling numbers (21 and 22 for > the two different cases)? >=20 > - give an estimate of how big the array now ends up being for > different configurations. >=20 > I think it ends up using that "scale" factor of 21, and basically > being "memory size >> 21" and then rounding up to a power of two. >=20 > And honestly, I'm not sure that makes much sense. So for a 1GB machine > we get the same as we used to for the bit waitqueue (twice as many for > the page waitqueue) , but if you run on some smaller setup, you > apparently can end up with just a couple of buckets. >=20 > So I'd feel a lot better about this if I saw the numbers, and got the > feeling that the patch actually tries to take legacy machines into > account. > > And even on a big machine, what's the advantage of scaling perfectly > with memory. If you have a terabyte of RAM, why would you need half a > million hash entries (if I did the math right), and use 4GB of memory > on it? The contention doesn't go up by amount of memory, it goes up > roughly by number of threads, and the two are very seldom really all > that linearly connected. >=20 > So honestly, I'd like to see more reasonable numbers. I'd like to see > what the impact of just raising the hash bit size from 8 to 16 is on > that big machine. Maybe still using alloc_large_system_hash(), but > using a low-imit of 8 (our traditional very old number that hasn't > been a problem even on small machines), and a high-limit of 16 or > something. >=20 > And if you want even more, I really really want that justified by the > performance / profile numbers. Yes all good points I'll add those numbers. It may need a floor and ceiling or something like that. We may not need quite so many entries. >=20 > And does does that "bit_waitqueue" really merit updating AT ALL? It's > almost entirely unused these days. I updated it mainly because keeping the code more similar ends up being=20 easier than unnecessary diverging. The memory cost is no big deal (once=20 limits are fixed) so I prefer not to encounter some case where it falls=20 over. > I think maybe the page lock code > used to use that, but then realized it had more specialized needs, so > now it's separate. >=20 > So can we split that bit-waitqueue thing up from the page waitqueue > changes? They have basically nothing in common except for a history, > and I think they should be treated separately (including the > explanation for what actually hits the bottleneck). It's still used. Buffer heads being an obvious and widely used one that follows similar usage pattern as page lock / writeback in some cases. Several other filesystems seem to use it for similar block / IO tracking structures by the looks (md, btrfs, nfs). Thanks, Nick