Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp981496rwr; Wed, 26 Apr 2023 08:40:24 -0700 (PDT) X-Google-Smtp-Source: AKy350ZNdq8oAtobqFvQfcoSciQ6dqz/hqFz1uQdg/4frz3kqYMqBqMMnTPTcBIm9m3xod4PEw8R X-Received: by 2002:a17:90a:c388:b0:247:2ff9:1cff with SMTP id h8-20020a17090ac38800b002472ff91cffmr19972981pjt.25.1682523624265; Wed, 26 Apr 2023 08:40:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682523624; cv=none; d=google.com; s=arc-20160816; b=SmM0b5q40JznYJd/rJ0tm3vpdl8kdMiFQm43im0zu+QhrBi/ZQWLmJz5UDl4dzStU5 c/rHlfW6+NCwND0Z3Hq9DIczZP127Pc7SiPmrHRUP13tALLvJNlzlj97xobmZLCjHsbX ZvuMqIswo+peAQLDEFdR3WunQVj4O9aCdTIDd0osDh7Lkp74t/hs+Tg4j07M01GZ5Afy wq1qiio4EUkbUdyF0m/+VoWf0mq04LLsF6dIY75M5996Y7bBSUfINm1wYaPrervY59YR /5ulGTgdfhNBcmeJpK5huSFo08dXrOXqOob/W/RBGMcdWaxtWOMfBM4TmrW9fYj+/U01 LvMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GPvsDH5jNOVR6Eyv2yuotNriNEuFABwoitK5mC3a5ek=; b=TDYlcl+Cv8pqKt6LLyOc0jZ5/HViI7dxiiwz9iEgn8oR94GLqWcgpbYLkMscZjeFRP fJGT+1GlrIJ5NaJMvBUWVCNnor91PzLSkfx10ltgVPOyrJwLOi879KhDtr+eO1GxArHX ZUGmZ9bFRMb6SrQD0G5fL1y2ApNsDDZuYRICqbDvVPu4JMT0oVDRrcrNfXh9CSVdRAjD 6dyXE+oYe6ocfpnAxWIT66oO7Pccvf6L6rxq7l5JXcw0TmTdSZWhc9pn9Ap9V4C/8Fg4 fFMmIE15UPC5TzSOFxH502FOLA1VC+tE1anOOrj49QmM/BYkyugdR1U6e4WuIYX/Y1s9 9cNA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b="Ep+byN//"; 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 bs1-20020a632801000000b005286be44da7si5204030pgb.706.2023.04.26.08.40.09; Wed, 26 Apr 2023 08:40:24 -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=google header.b="Ep+byN//"; 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 S241220AbjDZPY6 (ORCPT + 99 others); Wed, 26 Apr 2023 11:24:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45634 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240838AbjDZPY5 (ORCPT ); Wed, 26 Apr 2023 11:24:57 -0400 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04C9930C1 for ; Wed, 26 Apr 2023 08:24:56 -0700 (PDT) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-508418b6d59so13331352a12.3 for ; Wed, 26 Apr 2023 08:24:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1682522694; x=1685114694; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GPvsDH5jNOVR6Eyv2yuotNriNEuFABwoitK5mC3a5ek=; b=Ep+byN//ShUm0mEnGmNhxSFePnJp5vzi/a5Tbgi9cE9lQBsqLMsgePrOCr5nTLNIrp YBcbWvcF2e3Zf0LwQH9mG27s/jkD82N9kAWuTDHbxusogXZOODbKxbPKC9UaJQYOa+x/ MOMG6+B2CQe9elGCd/3sEkyhHrWtkDG77mvdI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682522694; x=1685114694; h=content-transfer-encoding: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=GPvsDH5jNOVR6Eyv2yuotNriNEuFABwoitK5mC3a5ek=; b=cGbRw3RZA9oGY8EfOBu+Q4cKoN3Pvc5dq5NC1D/5cD4Ua3tzQXoLRDvAiWF7NGenGa UyXjLjl48NLswk7Zcxf7hAvy+dtkuX+Gh80xG+SNlXgVeYufhnOTYXmR7m5q3XnkiEri 24V2l+9j9UKGROcjoiPXOKQTMn3Z/6ofSlhhVBmzlHOskksENloGiPzo33zzm+njIl/f JCQ+1CUUGcuN6VCbeqbmCUZEyWagJCiiWwrGToxklm7Q6P1+lVsei0SBlNAyL8sWi5cK wf0AsGHWvA+mTDgLLKjD6qif82WUy5GcF/oG2Jmto3Tf6Z9zAO5OaQGaN+5yC0w6DBZV a7Ug== X-Gm-Message-State: AAQBX9cNtNQUj8ZvxIO0guX4tFVUDsG9Qdj9aCROUE27sXSJF1JgsPjh uVNvMCu5qoyTB7nOUwcWeH2nQ3wcI4wLeFSxTcLOtw== X-Received: by 2002:a50:fb04:0:b0:506:7d3e:ade5 with SMTP id d4-20020a50fb04000000b005067d3eade5mr15820424edq.33.1682522694128; Wed, 26 Apr 2023 08:24:54 -0700 (PDT) Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com. [209.85.208.47]) by smtp.gmail.com with ESMTPSA id bq6-20020a056402214600b0050470aa444fsm6900987edb.51.2023.04.26.08.24.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 26 Apr 2023 08:24:53 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-508418b6d59so13331299a12.3 for ; Wed, 26 Apr 2023 08:24:53 -0700 (PDT) X-Received: by 2002:a05:6402:2c7:b0:502:61d8:233b with SMTP id b7-20020a05640202c700b0050261d8233bmr20090196edx.19.1682522693062; Wed, 26 Apr 2023 08:24:53 -0700 (PDT) MIME-Version: 1.0 References: <20230421221249.1616168-1-dianders@chromium.org> <20230421151135.v2.1.I2b71e11264c5c214bc59744b9e13e4c353bc5714@changeid> <20230422051858.1696-1-hdanton@sina.com> <20230425010917.1984-1-hdanton@sina.com> <20230426100918.ku32k6mqoogsnijn@techsingularity.net> In-Reply-To: <20230426100918.ku32k6mqoogsnijn@techsingularity.net> From: Linus Torvalds Date: Wed, 26 Apr 2023 08:24:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2 1/4] mm/filemap: Add folio_lock_timeout() To: Mel Gorman Cc: Doug Anderson , Hillf Danton , Andrew Morton , Alexander Viro , Christian Brauner , linux-kernel@vger.kernel.org, linux-mm@kvack.org, Yu Zhao , Matthew Wilcox Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 Wed, Apr 26, 2023 at 3:09=E2=80=AFAM Mel Gorman wrote: > > The reason I don't consider this patch a NAK candidate is that this is no= t > conditional locking as such because no special action is taken if the loc= k > cannot be acquired. If this comes from my rant against not having conditional locking for the O_NDELAY (well, the io_uring equivalent) IO path, then no, I don't think something like lock_page_timout() is "conditional locking". Some caller wanting to get the lock, but being willing to just go on and do something else after a timeout is fine. Within the context of something like memory compaction internally for the kernel that is fundamentally opportunistic anyway, that sounds fine to me. In fact, in contexts like that, even trylock is fine. We obviously have trylock in lots of places of the kernel. My "no conditional locking" is really that I do not think it's sane to have user IO fail with EAGAIN just because some data structure happened to be busy. It's a debugging nightmare with unlikely things that happen only in special conditions. Doing IO is not some "opportunistic" thing. We've actually had things like that before where people tried to make O_NDELAY mean "no locking" (I think that was driven at least partly by the old in-kernel web server patches), and it also causes actual problems with user space then busy-looping in a select() loop, because the select doesn't consider some low-level lock to be a waiting event. (The io_uring case is _slightly_ different from our historical issues in this area, in that the kernel can fall back to the user worker thread case, but it's all mixed up in that same IO path and that's why I absolutely hated that "if (X) trylock else proper_lock" approach). So a unconditional "lock with timeout" in the context of "we can just skip this if it times out" is perfectly fine by me. That said - the kcompactd code is not code I know, so maybe there are *other* issues with that patch, so this is also not an ACK from me. So please consider this just a "that is a very different case from the one I complained about". Linus