Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp135249rdb; Thu, 5 Oct 2023 20:48:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGvBIM7s767BJpbp2l9iEktKhlmMGF9U/1L9eb6KfNq1pEjuPdxqhGKYwjdi/LC+DGOD9Iq X-Received: by 2002:a0d:d986:0:b0:59c:8b3:6863 with SMTP id b128-20020a0dd986000000b0059c08b36863mr7837493ywe.43.1696564121179; Thu, 05 Oct 2023 20:48:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696564121; cv=none; d=google.com; s=arc-20160816; b=PW9VB4dU4aAhJo9qrTW7uhcLpTh8ikZ0y+4GwHPM2ef2Ryg3qoJxqeQoE523y8ZEcM WHKlyyAVnXawf6PHr8aLImjE8xwm8490ZWVChPabx87yJBnIEb+PVuqnNCfZOv7dbDpj v7EsRjIcazvojaQdgysN2iv/KgKHOrbGLuI+vAEp076syIPoShcyGDLKE+SNJ26bkqH6 DwVrXLz0P8zDE/iv9PPZmoxOW1wbTVtJaeZBYeu3AZS7tc6eA5qx5ZAC7OxB5+B1Mx76 IWFeRLVvN/bMppOO9WM5q8wXlHY6Iqs2PbVrydjwc0Xdoe+n+qvlgp0JuMSQtoP3VZYo oHMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=8BzpawJSlmNG1RzfXiwjSDiv93YoIZJw/vsqhpYIp/Q=; fh=9L2ksTgvSTosNOBTlmCVq64A/w5OS8WcA0QoSjSQXJE=; b=OrzvmTLXoKehlT5R5CZiXuCC1H27bqkBFe4OTHhFbacbX51jOEzB4MBbQbaocb9X+b 2+CZqcGA8aAtBlomqUx1Th0mg0NCk+5WLn32fwfVuLkQSd9ZS5Zw1trTipf+RPALaeLr vhv1KCUyIAsSStISlIq5mltVQNFOUXsuAafWheAlVexXFwWCeVCAEPjMF+zfnpFx9y79 HPdmSE8Yzo+etGWLG2auEso639HHcOqTL8FJOpmM79A3lHqSBH7e3eAtXPHNz8FkNqeL geKTiok9iVTwnqjtlfQblnMIhNB8ZzBiZVRC3v7KOCugHkXlJjV62T1oGZ8Pl1zXXEqC Rekg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="f/OGuaCU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k14-20020a634b4e000000b00565e0624182si2834437pgl.404.2023.10.05.20.48.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 20:48:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="f/OGuaCU"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 84BCF806D832; Thu, 5 Oct 2023 20:48:38 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229850AbjJFDsP (ORCPT + 99 others); Thu, 5 Oct 2023 23:48:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjJFDsN (ORCPT ); Thu, 5 Oct 2023 23:48:13 -0400 Received: from mail-yw1-x1132.google.com (mail-yw1-x1132.google.com [IPv6:2607:f8b0:4864:20::1132]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA47FDB for ; Thu, 5 Oct 2023 20:48:11 -0700 (PDT) Received: by mail-yw1-x1132.google.com with SMTP id 00721157ae682-5a1d0fee86aso20183467b3.2 for ; Thu, 05 Oct 2023 20:48:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1696564091; x=1697168891; darn=vger.kernel.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=8BzpawJSlmNG1RzfXiwjSDiv93YoIZJw/vsqhpYIp/Q=; b=f/OGuaCU0SoRSGcpMPW2fHUjM6DB4d7woZmS/34qt0pWhC60F/wcBp4C4cgYbZRkvC oabv8CMt/UnM1Ujvi+j1PcagsrXvhcynEXrLnGb1rAo7MXvQvCERZQo1NjpRnITOqkzv XbyzkEBit8q86/06hkiCzCx1ghuAFE1Df9R4pXWqbxYxZQ2Z2pMjA+YHDDs0Sp7uA71X Qqie+Gt0E2yscQDPAsKcIqa4ep81fcNuVQsPOmxH8ZhG+smO7cgWKmEt51lrlUld5CUa eLxQgdI6wQbnvq7PFdXch/JmunzjIlozqWmfV1GrYecJnZMvJT5uzGL/Z4+5EDWmmeR3 XlCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696564091; x=1697168891; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=8BzpawJSlmNG1RzfXiwjSDiv93YoIZJw/vsqhpYIp/Q=; b=gQELQ09FpOQ2mVzXHn0GTAciW/pPh2ILMkKg5j/u4Lf1I3W5UIF2j+n6kEcJqkva57 eW3LfWj4AnMM8CEfSfJNOtasWX4/5O3NIb7Ct+6dTCPL7DlEzru2uGNSGoWg8nAUhkkc CHUPdt6/CAJsRL/YqG+SH8SVPvZ2bMn2JCGTbyNd18bJX459GrHK1+01CCxF6CFmwk64 hLDHKKqOw1hVkJUvvTG9ukZBrV2wy4a9SBqK09ljALdOE8EKXQuKw8bShPltIfE+pOJV ZUxeZfcmTlOlyridBJbAxHAwJNTTv3Qm8rYNFkIth/9SMV7Vj66/Aw3vnCpHVp5R1mvt eXfQ== X-Gm-Message-State: AOJu0YzuAqwLjs/9EhLEU14eEt8z+vWBRuNAv6XCc4CHY2mJ9bTN2Q8y EOCJ4efhw3adITMQ2z3FNaLnEA== X-Received: by 2002:a0d:d54f:0:b0:5a1:f0f8:4280 with SMTP id x76-20020a0dd54f000000b005a1f0f84280mr7981311ywd.22.1696564090019; Thu, 05 Oct 2023 20:48:10 -0700 (PDT) Received: from ripple.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id v143-20020a814895000000b0059be3d854b1sm978159ywa.109.2023.10.05.20.48.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 20:48:08 -0700 (PDT) Date: Thu, 5 Oct 2023 20:48:00 -0700 (PDT) From: Hugh Dickins X-X-Sender: hugh@ripple.attlocal.net To: Jan Kara cc: Hugh Dickins , Andrew Morton , Christian Brauner , Carlos Maiolino , Chuck Lever , Matthew Wilcox , Johannes Weiner , Axel Rasmussen , Vlastmil Babka , Sasha Levin , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 3/8] shmem: factor shmem_falloc_wait() out of shmem_fault() In-Reply-To: <20231003131853.ramdlfw5s6ne4iqx@quack3> Message-ID: References: <6fe379a4-6176-9225-9263-fe60d2633c0@google.com> <20231003131853.ramdlfw5s6ne4iqx@quack3> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Thu, 05 Oct 2023 20:48:38 -0700 (PDT) On Tue, 3 Oct 2023, Jan Kara wrote: > On Fri 29-09-23 20:27:53, Hugh Dickins wrote: > > That Trinity livelock shmem_falloc avoidance block is unlikely, and a > > distraction from the proper business of shmem_fault(): separate it out. > > (This used to help compilers save stack on the fault path too, but both > > gcc and clang nowadays seem to make better choices anyway.) > > > > Signed-off-by: Hugh Dickins > > Looks good. Feel free to add: > > Reviewed-by: Jan Kara Thanks a lot for all these reviews, Jan. (And I particularly enjoyed your "Autumn cleaning" remark: sweeping up the leaves, I've been glad to have "Autumn Almanac" running through my head since reading that.) > > Looking at the code I'm just wondering whether the livelock with > shmem_undo_range() couldn't be more easy to avoid by making > shmem_undo_range() always advance the index by 1 after evicting a page and > thus guaranteeing a forward progress... Because the forward progress within > find_get_entries() is guaranteed these days, it should be enough. I'm not sure that I understand your "advance the index by 1" comment. Since the "/* If all gone or hole-punch or unfalloc, we're done */" change went in, I believe shmem_undo_range() does make guaranteed forward progress; but its forward progress is not enough. I would love to delete all that shmem_falloc_wait() strangeness; and your comment excited me to look, hey, can we just delete all that stuff now, instead of shifting it aside? That would be much nicer. And if I'd replied to you yesterday, I'd have been saying yes we can. But that's because I hadn't got far enough through re-reading the various July 2014 3.16-rc mail threads. I had been excited to find myself posting a revert of the patch; before reaching Sasha's later livelock which ended up with "belt and braces" retaining the shmem_falloc wait while adding the "If all gone or hole-punch" mod. https://marc.info/?l=linux-kernel&m=140487864819409&w=2 though that thread did not resolve, and morphed into lockdep moans. So I've reverted to my usual position: that it's conceivable that something has changed meanwhile, to make that Trinity livelock no longer an issue (in particular, i_mmap_mutex changed to i_mmap_rwsem, and much later unmap_mapping_range() changed to only take it for read: but though that change gives hope, I suspect it would turn out to be ineffectual against the livelock); but that would have to be proved. If there's someone who can re-demonstrate Sasha's Trinity livelock on 3.16-with-shmem-falloc-wait-disabled, or re-demonstrate it on any later release-with-shmem-falloc-wait-disabled, but demonstrate that the livelock does not occur on 6.6-rc-with-shmem-falloc-wait-disabled (or that plus some simple adjustment of hacker's choosing): that would be great news, and we could delete all this - though probably not without bisecting to satisfy ourselves on what was the crucial change. But I never got around to running up Trinity to work on it originally, nor in the years since, nor do I expect to soon. (Vlastimil had a good simple technique for demonstrating a part of the problem, but fixing that part turned out not fix the whole issue with Trinity.) Hugh