Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2561379rwd; Fri, 9 Jun 2023 13:12:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7c2cEq2zH0JuzPlP0QTKaG0E3dE/EWnxiAEk/NWkCtpUMDDbxETmLmHEPkSh4aApwxAu02 X-Received: by 2002:a05:6a21:670a:b0:10b:fe06:97dd with SMTP id wh10-20020a056a21670a00b0010bfe0697ddmr2182515pzb.54.1686341534239; Fri, 09 Jun 2023 13:12:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686341534; cv=none; d=google.com; s=arc-20160816; b=Hpmr2uTWmu92Cv5eIcWiHJRx2yGy98Xdqi+fUS3YEdh7sscgOkNElRCXGgojxMEL4x IRpIEwQ+6LJ+wpJXG77MBPiy/hze2uYzdtUwksgrzsf8FB2VNxYbFMursL9KUSwEhjwB 34he3jkzneQT9KIjkF9hAi2Gh4cMSobc+XVZNAWEQeVUcKiDO+U9EmdNTdIjRewuHLPn b8ZyrqNgov1XYH5kwJNXSLe/4eLpDxUgZbxIQpJ5e4tDxvarOMllaTarx4cQJlC20FhQ X7//ZTyGIwAUqqppSJoFAu5NGRXJsizKuBsCxu2cMxtasg26EP5a5vUkBImikoQN59ft NLsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=0HXVmnlVKBq0ssRDEmsoSJn11Ep+kO0iOz1cvxDsGzc=; b=U+YOJCaIkzpGYkmpTjl3UfXxnY2i/EM7Qaf11sABSKzCZtnao9Pj/a53yNglryt+e0 n2ps0g3Hl20y7I0YagklNwQvMkWfojxEEYcMciOs5m/NDCHEBdevRvM+3+jhp4hjpGkL IBKH//0ou2dag6M6PhCYUS5xdTDSc7nsERms4h2xaFZcS2dbz8/BvDuesnbxWm2CcdDf /+mXjtnWfNoLAoLWQiTVFUAKMxi8dcz84E5nLpV+Hye4jCNCpDj2vfM4YKLNLUafsnhJ QdK8Fff/XDu4OyislxwLU6Vb+bHWiLY/342VgxQtTG6PTLDaoqlUI74TUgYsDMsrzFLL yRMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=vT+xFxto; 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 a28-20020a63705c000000b005250c235984si3225360pgn.860.2023.06.09.13.11.56; Fri, 09 Jun 2023 13:12:14 -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=@infradead.org header.s=casper.20170209 header.b=vT+xFxto; 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 S230134AbjFIUK3 (ORCPT + 99 others); Fri, 9 Jun 2023 16:10:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56400 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229517AbjFIUK1 (ORCPT ); Fri, 9 Jun 2023 16:10:27 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957991B9 for ; Fri, 9 Jun 2023 13:10:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=0HXVmnlVKBq0ssRDEmsoSJn11Ep+kO0iOz1cvxDsGzc=; b=vT+xFxtoVOxsh/JuBcSwVFlLSy r6fZ4SHqauLNA9/u3Aiy1rp8c0czsXItXrtZECi7eXEGWxbUikInvpRcBGgyU3pF7fmsLlVE1qF8D KlTB7x/z/xA408e5tWzxSWZ2SrKK2vlKiiLdgA2/GKBtbGYfrZtOm7PD04m3Twqn8QTvFiUNlxhZl BvVy0nx8n7c+20mtzJtpismK3vaH8HCZ0OvYcGWesw2xcvDU7WeRHU5bsFf2wRS3id+yilq7q4/CL ENMc/K75BorOzls2PQnRBSJCJ6ayKPlsuMWDVDtSHWMqZVcCWh5DQirBp3/rlbrl1m62gpBb/60aS s+7lw45Q==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1q7iRD-00Gzss-8m; Fri, 09 Jun 2023 20:10:23 +0000 Date: Fri, 9 Jun 2023 21:10:23 +0100 From: Matthew Wilcox To: Sidhartha Kumar Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, songmuchun@bytedance.com, mike.kravetz@oracle.com, david@redhat.com, nphamcs@gmail.com, jthoughton@google.com Subject: Re: [PATCH 2/2] mm/hugetlb: add wrapper functions for interactions with page cache Message-ID: References: <20230609194947.37196-1-sidhartha.kumar@oracle.com> <20230609194947.37196-3-sidhartha.kumar@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230609194947.37196-3-sidhartha.kumar@oracle.com> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Fri, Jun 09, 2023 at 12:49:47PM -0700, Sidhartha Kumar wrote: > +++ b/fs/hugetlbfs/inode.c > @@ -617,20 +617,19 @@ static void remove_inode_hugepages(struct inode *inode, loff_t lstart, > struct hstate *h = hstate_inode(inode); > struct address_space *mapping = &inode->i_data; > const pgoff_t start = lstart >> huge_page_shift(h); > - const pgoff_t end = lend >> huge_page_shift(h); > struct folio_batch fbatch; > pgoff_t next, index; > int i, freed = 0; > bool truncate_op = (lend == LLONG_MAX); > > folio_batch_init(&fbatch); > - next = start; > - while (filemap_get_folios(mapping, &next, end - 1, &fbatch)) { > + next = lstart; That's suspicious. Surely it should be next = lstart / PAGE_SIZE; > + while (filemap_get_folios(mapping, &next, lend - 1, &fbatch)) { and 'end' is supposed to be a pgoff_t, so lend - 1 is also suspicious. > - index = folio->index; > + index = (folio->index) >> huge_page_shift(h); You don't need to use brackets here. While C's operator precedence is legendarily confusing, the arrow operator binds far tighter than the shift operator.