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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 70C05C54EAA for ; Fri, 27 Jan 2023 19:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233745AbjA0TZ4 (ORCPT ); Fri, 27 Jan 2023 14:25:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbjA0TZw (ORCPT ); Fri, 27 Jan 2023 14:25:52 -0500 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8829D7E6E9 for ; Fri, 27 Jan 2023 11:25:51 -0800 (PST) Received: by mail-ej1-x630.google.com with SMTP id ud5so16418872ejc.4 for ; Fri, 27 Jan 2023 11:25:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=XsokS1YP+ed5nK3QU8sNOQqirFUSIf3rP7aib6Oe1Js=; b=gcQ2G1/dQOADZqdeXGdob2JCT0R19DKOkThzM8086d+XPChpdlL1O/HbyY/n4Y1Mib kJKg8P5v723hpFPJl4hBVx0pTFYgX1A7HTvUtpsYF97hn7ONu8XXAJ18HfyW+PvWdjMm GPd8oYLzRqBi0f58p7mAkIMY/2hQt5jB/YcBM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=XsokS1YP+ed5nK3QU8sNOQqirFUSIf3rP7aib6Oe1Js=; b=ApD3ioMoVptTYjPyk9WHuh6zxGyRq4dEHCJe/DA7V4DLOdCzmZr8ol/KGgPlRKom6I HFcHro6FJyozCra9kbksTFY6sMtnJeZcXJXJqyBsu2B2hKazAOjhIZxGZ4JfF6sSsNva 4bPDO3VJCxdHb77hoh54AJ6yTab8ZUhcB5moAcTQetVQEhmIpPcKLDQ+UgqFsMC9wB+h odjEJkx3M6T3yUI68owbEwqT9BJHZrGB1Xn/MyStohmmmychin8z0WVq6+NGA3+X0sb2 pkfFM+xAwsDqRWo3s6z3xX5K5H7xMumIUsc4K6CDlcdJP7j44C+yTwJgR+T5HoZNn+c0 fe/Q== X-Gm-Message-State: AO0yUKU2ogf+MnOcnDsSco+8TXarbK+JrgGU6etKdq8D1Yp3h5EfwIT+ TSdcWPvBMWWNaQ/L7acyd1JAuEc4GOYbbTtr6IE= X-Google-Smtp-Source: AK7set/j5UtvJ3nX/7fuYwwwOnmXmeYP6CCmJ+VobG7o4hhbmgdRqmqsyI/y0WGhJ/15i38Vc590oQ== X-Received: by 2002:a17:906:65d8:b0:878:5c22:6e03 with SMTP id z24-20020a17090665d800b008785c226e03mr7088698ejn.73.1674847549835; Fri, 27 Jan 2023 11:25:49 -0800 (PST) Received: from mail-ej1-f47.google.com (mail-ej1-f47.google.com. [209.85.218.47]) by smtp.gmail.com with ESMTPSA id z4-20020a170906714400b0087223b8d6efsm2761689ejj.16.2023.01.27.11.25.49 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 27 Jan 2023 11:25:49 -0800 (PST) Received: by mail-ej1-f47.google.com with SMTP id qw12so495086ejc.2 for ; Fri, 27 Jan 2023 11:25:49 -0800 (PST) X-Received: by 2002:a17:906:d9ce:b0:878:70c8:14f0 with SMTP id qk14-20020a170906d9ce00b0087870c814f0mr1906275ejb.20.1674847548910; Fri, 27 Jan 2023 11:25:48 -0800 (PST) MIME-Version: 1.0 References: <20230118150703.4024-1-ubizjak@gmail.com> <20230118131825.c6daea81ea1e2dc6aa014f38@linux-foundation.org> <913c01d41f824fa8b3400384437fa0d8@AcuMS.aculab.com> In-Reply-To: From: Linus Torvalds Date: Fri, 27 Jan 2023 11:25:31 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] lib/genalloc: use try_cmpxchg in {set,clear}_bits_ll To: Al Viro Cc: Mateusz Guzik , Uros Bizjak , David Laight , Andrew Morton , "linux-kernel@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 26, 2023 at 7:54 PM Al Viro wrote: > > > > > And extending the LOOKUP_RCU window all the way over the stat info > > gathering would require a lot of care, and force us to expose the > > kinds of things we do for LOOKUP_RCU in namei.c to fs/stat.c too. > > Interesting... So basically a variant of filename_lookup() that > fills struct kstat instead of doing that to struct path? Well, kinda. You still want the fallback to struct path in case you can't fill in the kstat without it (because the filesystem needs to do something under RCU). So I think what you'd really want is something like a special version of filename_lookup() that is then given an optimistic "call this function under RCU before you finalize the path". And then, *if* the filesystem can do the kstat lookup etc under RCU, it can just fill it in there, and instead of finalizing the path, we can just do terminate the walk without ever doing the try_to_unlazy() that legitimizes the path. I suspect it's fairly close to how we do d_revalidate() for the path component, except we'd do this not per-component, but as a "for the final result, let's do one last thing under RCU, and if it succeeded there, we don't actually need the path at all after all, because we've already done everything we needed". I think the only really relevant situation this is the case is basically the stat() family of functions, since those don't actually care about the path after the operation. But there are other cases that have that error = filename_lookup(dfd, filename, lookup_flags, &path, NULL); ... do something simple once ... path_put(&path); pattern where we just do the 'put' on the path and don't have any other use for it. The io_uring xattr code matches that same pattern, for example - but may simply not be worth worrying about. So either some generic "callback under RCU before we finalize it", or we could make it very specific for just "fill in kstat and don't bother finalizing the path when this flag is set" > Looks like the main obstacle is how to deal with duplication between > that thing and vfs_getattr{,_nosec}(); I think we'd need something like a new ->rcu_getattr() function, and filesystems that can do getattr under RCU would just set that function pointer. I dunno. I didn't look at it all, but it *feels* like you could have something that just says "if I have this function, and calling it returns success, then we can just do "terminate_walk()" without ever doing "try_to_unlazy()". Linus