Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1155909pxu; Fri, 27 Nov 2020 00:41:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJynmE0mXu0Iv2F5uNcTeqmyt3B9N0fbsTTtQ4M1MpcDwBE9RSH8kiSkBCXmgrBX2MbWDJG0 X-Received: by 2002:a17:906:11d0:: with SMTP id o16mr6620756eja.25.1606466499505; Fri, 27 Nov 2020 00:41:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606466499; cv=none; d=google.com; s=arc-20160816; b=Z6hRIW8h5H3lti5UWzP9/CoYsVm9IsQuKmPhKR+TYTJG8+WnfCnjRm2D1fTZp+7H6/ CM6lvweQcIUwQ4sRUB9lFsAL/H5q0BEaqtG0aH6+GCSnG8FTmXAFW2KFdx9JjMGJKg4U kABCiO1O2mJe0KRNP+6fnZ6d6m+PmNMijkUu5rnFSQBQC7R7eUHldFCVmAJnXP7OMzZY KkMmoEMX/BcaajlC07tTCY4vL/zdRcaN5TsOrjfMuHMqUrbOgaaKdFnhv4yne7pb12B4 /fGxaEpWNmKqDyO6BhmY4o9/o/NkYqpdwA3V6Nx8HgV8/yByH5GQdIi0fohv8b9Jgpgz JtCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:dkim-signature; bh=ViCmWRKE+pPFgMfgXX95fmQBtr/0Bp2EoCIrnvSRlR0=; b=g9bfK27p5UjUFeD21huHEOGjrNFizzlh9qXc2ec1i8vGgr/JrpHXt1WEkJJzjuv2++ UH9Y++4J/moafAM1B5bY4YU2bCWsfhx3EY3GmR9JgPc1nIFNDC5mHdVl2hX3cdzzN41x v3magwVtmGXiQEbbM6gmMJMfiaM9kUEHjqIekx8HTVFpVHDMRaZZjWMAfaJ+7hDG9HB+ 1OXTAfni0xzc/NtkWBrDhBbl/ss2Rqy8+lsr1nI59MTfSZoQB1DUssSJPEllF7eA0vUP Qcj8GG6Cap6K3ZaDUUZmJxZNlgZNuG+hRTmqF3053z9TpE+8SmBc2itgHIHbosU4n8zd 1yiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v2xW4TCd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hr1si4250386ejc.474.2020.11.27.00.41.16; Fri, 27 Nov 2020 00:41:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=v2xW4TCd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728153AbgKZTZP (ORCPT + 99 others); Thu, 26 Nov 2020 14:25:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55426 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729715AbgKZTZP (ORCPT ); Thu, 26 Nov 2020 14:25:15 -0500 Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com [IPv6:2607:f8b0:4864:20::243]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10AC5C0617A7 for ; Thu, 26 Nov 2020 11:25:15 -0800 (PST) Received: by mail-oi1-x243.google.com with SMTP id h3so3307494oie.8 for ; Thu, 26 Nov 2020 11:25:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=ViCmWRKE+pPFgMfgXX95fmQBtr/0Bp2EoCIrnvSRlR0=; b=v2xW4TCdDnILHxtMD8+qN7xcXERVQhE9QzfxnnXsewMQpCys3+AtvNtATD4sabxHIY rb5zV3C85W5dyMzlXrJX93jNM1Pkc2VJ9bY/hBs1NHsqSgq0JJj8Pac7n6px8GmMtu+o vTm7KUhR1W9n7dYmchbQNm7yCgArHuBhSlhDL0iQnbfyPRlrfZiIBncU4i0lWsGzz04O MF7DrFjtk1GAydq/oJtLsM3l6BGDzxI0vl7jRVQbi79URE7rRTOfB2e67DZ7PwNyETab MkEqePjG5SSLNyAosQujDaxYibQ4gn46jl+7PSlUKHhqEbJvv4hGjA+Uz5W0Qw2SBxUq QOOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=ViCmWRKE+pPFgMfgXX95fmQBtr/0Bp2EoCIrnvSRlR0=; b=VEZkGr87z24wwLMCPlDsQg7sD0iuirfiSY3rSdclHLttG071BwwA/h5X8EsC1SZmoi lEoJk8AcsKgNBY1Ne0ZthcjEbbeTPa69MY1XyuX7r3JuUkv0Ic/IHROJDIEy54eECn+M sNQdn6YLgHqm1QbnsoWL+5rVOJb2bEqcZgmla+j0IpBraiYXG8FnxCiwcxsM9cVu3286 AdIi4DljKIww+sh3RAtBPaSRRuJYzPpYnTDAyvNee+frqtqFanUF1FJkMBrpSnceYFoy EmtQSCEJGOoTL/0Xy9uban0ik6AYwqygysgGoz/0a8zWeU2TeG9LsZkYOGGLAt0NFCOO 7OMA== X-Gm-Message-State: AOAM530DkK9Xse08LJyMoQhzZa8uQwfaDRDzKZK4RQFnRhny0lIDw6ZN T4Rc4HduR3uc25aTl+S4FT+3ag== X-Received: by 2002:aca:d586:: with SMTP id m128mr2928947oig.73.1606418714084; Thu, 26 Nov 2020 11:25:14 -0800 (PST) Received: from eggly.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id z12sm3348947oti.45.2020.11.26.11.25.12 (version=TLS1 cipher=ECDHE-ECDSA-AES128-SHA bits=128/128); Thu, 26 Nov 2020 11:25:13 -0800 (PST) Date: Thu, 26 Nov 2020 11:24:59 -0800 (PST) From: Hugh Dickins X-X-Sender: hugh@eggly.anvils To: Matthew Wilcox cc: Hugh Dickins , Andrew Morton , Jan Kara , William Kucharski , Linux-FSDevel , linux-mm , Christoph Hellwig , Johannes Weiner , Yang Shi , dchinner@redhat.com, linux-kernel Subject: Re: [PATCH v4 00/16] Overhaul multi-page lookups for THP In-Reply-To: <20201126121546.GN4327@casper.infradead.org> Message-ID: References: <20201112212641.27837-1-willy@infradead.org> <20201117153947.GL29991@casper.infradead.org> <20201117191513.GV29991@casper.infradead.org> <20201117234302.GC29991@casper.infradead.org> <20201125023234.GH4327@casper.infradead.org> <20201125150859.25adad8ff64db312681184bd@linux-foundation.org> <20201126121546.GN4327@casper.infradead.org> User-Agent: Alpine 2.11 (LSU 23 2013-08-11) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 26 Nov 2020, Matthew Wilcox wrote: > On Wed, Nov 25, 2020 at 04:11:57PM -0800, Hugh Dickins wrote: > > > + index = truncate_inode_partial_page(mapping, > > > + page, lstart, lend); > > > + if (index > end) > > > + end = indices[i] - 1; > > > } > > > - unlock_page(page); > > > > The fix needed is here: instead of deleting that unlock_page(page) > > line, it needs to be } else { unlock_page(page); } > > It also needs a put_page(page); Oh yes indeed, sorry for getting that wrong. I'd misread the pagevec_reinit() at the end as the old pagevec_release(). Do you really need to do pagevec_remove_exceptionals() there if you're not using pagevec_release()? > > That's now taken care of by truncate_inode_partial_page(), so if we're > not calling that, we need to put the page as well. ie this: Right, but I do find it confusing that truncate_inode_partial_page() does the unlock_page(),put_page() whereas truncate_inode_page() does not: I think you would do better to leave them out of _partial_page(), even if including them there saves a couple of lines somewhere else. But right now it's the right fix that's important: ack to yours below. I've not yet worked out the other issues I saw: will report when I have. Rebooted this laptop, pretty sure it missed freeing a shmem swap entry, not yet reproduced, will study the change there later, but the non-swap hang in generic/476 (later seen also in generic/112) more important. Hugh > > +++ b/mm/shmem.c > @@ -954,6 +954,9 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > page, lstart, lend); > if (index > end) > end = indices[i] - 1; > + } else { > + unlock_page(page); > + put_page(page); > } > } > index = indices[i - 1] + 1; > > > > } > > > + index = indices[i - 1] + 1; > > > pagevec_remove_exceptionals(&pvec); > > > - pagevec_release(&pvec); > > > - index++; > > > + pagevec_reinit(&pvec);