Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp4936776rwi; Mon, 17 Oct 2022 12:59:31 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7O8M6EIysXKUOogKd5yJBpA1oAwjWSB8KpYYwDd3K+V6NSedv8bFxIV1j59a1Pudgb8h1v X-Received: by 2002:a63:4283:0:b0:457:dced:8ba3 with SMTP id p125-20020a634283000000b00457dced8ba3mr12077370pga.220.1666036771209; Mon, 17 Oct 2022 12:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666036771; cv=none; d=google.com; s=arc-20160816; b=VOvE2oGX18lT68LNTkpgMqJSBZ4qOYlWxroT4rsAYm8bS69f2B4ysAPdSUTybx3oKS 15dIaCFLuoXO9ED5OpqvWzlwSzD51Z/jQzx+Rtc8SoNZyHWkcih6iRPYWRR9wpzLBpXE o0tdLORKy83jvDyi0tOFceucmqhEGanVig4dSeH95P5nDLO2BmwZIoSrxRKVX+hkWKTq T4iX7DxdxmYdAobBmtPVD5iBOvwROd8defSJD8A+jQnOA0FmBMbrH9DSRrNp72Yu+lan 0nB1oBslrvmP5kkFHLzHHctO/HOrkgQZlhARHqGOYYNkO7k7xppuhsppY2Xoohyx7UBf tawg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=11HlMSQgh2+1m4prM5hBOZCjfPivio1t8D+HJv6iXrE=; b=gq7KTOnPoS/AbX3c9ABbOe7CAPFrHE5tRPuSkd+zrQbR79ieCQpXyxxIYH5qtkn90u rNygcvSlpTmYYzixr77zCvra1IRsfKerATVDxjg8HGoi9EdgtqBDL/bLCxs9Kr0poT3M jZMrnW3+1LOnXETBSclhn/T97+6v8CgcycjfVLXW6PyQjb6Vfzw03evSJZ8FN/FHKYqs of6EWP5Iu9YnfCaGXN4vSurPRZ1pkcwGNrWrqim8H7a4Ivuby9MvKPtkLDuLOEXJdOcg b1ICgmx/1LisLEt9VmaO9+cPYMH+OPRaINM17yTmZBCLy3Tq/RUVMuZAadeq5ZYtO8xf Hiig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=Qqf6jWDr; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d1-20020a17090a8d8100b001fde53d5d79si18528186pjo.5.2022.10.17.12.59.18; Mon, 17 Oct 2022 12:59:31 -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=@gmail.com header.s=20210112 header.b=Qqf6jWDr; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230401AbiJQTiG (ORCPT + 99 others); Mon, 17 Oct 2022 15:38:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47620 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230111AbiJQTiB (ORCPT ); Mon, 17 Oct 2022 15:38:01 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AC4F7170C; Mon, 17 Oct 2022 12:38:00 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id 207so14505133ybn.1; Mon, 17 Oct 2022 12:38:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=11HlMSQgh2+1m4prM5hBOZCjfPivio1t8D+HJv6iXrE=; b=Qqf6jWDrDZvWOGO4mY2ZGxVxgAh7R1tkR0Jjq9c4ilfW90N7wx58GWNtMZKlnuWLPC U5teH3PTFAjeT7dlEM7EoTRpVXoEOIUEQQoaQwYMPr1ISM6DDsbpnhda4eQs2y63NzU0 /BIjOb6KK8YYEVE1FvR8vmhthMgW3+wL9qc2ILLLxCn8/0cKKQolwZm2Rv89ll4HX4s3 pZgIXUNqEG9RW4BpEIs6dkJZmr633WQqJxMJyuEcKqgCsClVEP7Bkp0MDNLbS86BXWpN P0/Pa6SigUrF/ejkkIVNYx5oiS+UMCJuAOmtAIHj4yaBlTPlwhQBGt8xPtR1C3ooIvF5 ca0g== 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=11HlMSQgh2+1m4prM5hBOZCjfPivio1t8D+HJv6iXrE=; b=IFxeKOXSs5/AOaDk4Q7szasoA2SZPqjGI13FpFNxhXcfi/qyqzcKddGSC7WjNZVXXj fLWgf3W3vjLyAjfVMTh/x+zaKh7ziGYm/W3Iq5izR1KmrrqAZHXrMkCwc7OX4Wvyy6TB DABNwA/FrSnuMb1OycN+A3VhRp5ncjtiM4Mgn9MLT15qLh9jDkQVau9+AChRN2X44qAz Lc8s91c464iqnJVPz0LVa81Xs0bNH3Xpp3Xy4U84L7NPnDyngvObTmnBoesFnyUYl8+h FPeLwlXMSlPkm6lYs06IqH8I6SdMqTtEiaZBG63MJoyZuCD+beCQWEIrlbmYJTwXeKA7 YiKQ== X-Gm-Message-State: ACrzQf1FxFTH0GYC4Jv6CR45/bqc4sBbrVcJAfp/S+eM+rM6qoRiLotw z7fxN/Us3PnjKFyZDEhfu0btbj8k1AM0xme2LSw5UiIejn0= X-Received: by 2002:a25:810f:0:b0:6bc:a66f:6763 with SMTP id o15-20020a25810f000000b006bca66f6763mr11123241ybk.355.1666035479638; Mon, 17 Oct 2022 12:37:59 -0700 (PDT) MIME-Version: 1.0 References: <20221017161800.2003-1-vishal.moola@gmail.com> <20221017161800.2003-2-vishal.moola@gmail.com> In-Reply-To: From: Vishal Moola Date: Mon, 17 Oct 2022 12:37:48 -0700 Message-ID: Subject: Re: [PATCH v3 1/2] filemap: find_lock_entries() now updates start offset To: Matthew Wilcox Cc: akpm@linux-foundation.org, hughd@google.com, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Mon, Oct 17, 2022 at 9:56 AM Matthew Wilcox wrote: > > On Mon, Oct 17, 2022 at 09:17:59AM -0700, Vishal Moola (Oracle) wrote: > > +++ b/mm/shmem.c > > @@ -932,21 +932,18 @@ static void shmem_undo_range(struct inode *inode, loff_t lstart, loff_t lend, > > > > folio_batch_init(&fbatch); > > index = start; > > - while (index < end && find_lock_entries(mapping, index, end - 1, > > + while (index < end && find_lock_entries(mapping, &index, end - 1, > > Sorry for not spotting this in earlier revisions, but this is wrong. > Before, find_lock_entries() would go up to (end - 1) and then the > index++ at the end of the loop would increment index to "end", causing > the loop to terminate. Now we don't increment index any more, so the > condition is wrong. The condition is correct. Index maintains the exact same behavior. If a find_lock_entries() finds a folio, index is set to be directly after the last page in that folio, or simply incrementing for a value entry. The only time index is not changed at all is when find_lock_entries() finds no folios, which is the same as the original behavior as well. > I suggest just removing the 'index < end" half of the condition. I hadn't thought about it earlier but this index < end check seems unnecessary anyways. If index > end then find_lock_entries() shouldn't find any folios which would cause the loop to terminate. I could send an updated version getting rid of the "index < end" condition as well if you would like?