From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91B50C433EF for ; Fri, 4 Feb 2022 20:00:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2E35D6B00A0; Fri, 4 Feb 2022 14:59:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 509226B0099; Fri, 4 Feb 2022 14:59:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 99F266B009E; Fri, 4 Feb 2022 14:59:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0044.hostedemail.com [216.40.44.44]) by kanga.kvack.org (Postfix) with ESMTP id A4BCB8D0001 for ; Fri, 4 Feb 2022 14:59:08 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 6B6A09367D for ; Fri, 4 Feb 2022 19:59:08 +0000 (UTC) X-FDA: 79106161176.09.57E1979 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id 1AB2740004 for ; Fri, 4 Feb 2022 19:59:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=WDil5dypwvwr0pJhzlmwMCjRq+EI+jeEJkZckLIBlgY=; b=c0dzG4llF/3b84Bw55bDXwjWWG U2yxsxG8cTJvhBEwjBNYS4gPj3S2uOWmr3Bv2IZxy5kFyx415wC143anDVbiZFstnPdNlGWvh2l9J UC/J/tPK62ut1RJ7uBm09b8fm4VMmZNhTFnBCqP/vdUqPhelrD8FX5pOGV3fC1p0aA5Agi1UASqbK UMTEAbS76MFZDTrXAq3GEW6pN6Wal7tRucg1W0PoUFK+vbXmpu55ZP7Wmf2uz8m1PL2L9kUdBC5lm 4kqXPSHrUXBA+xuTeicL1bgLidy7eacG+L+B+GqBo6Ul/PLCdtteCJXgjBMEwKHWX3M14wWj2D8Jv qkRnh9CA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nG4jX-007Ln3-Eb; Fri, 04 Feb 2022 19:59:03 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , linux-kernel@vger.kernel.org Subject: [PATCH 39/75] mm: Add folio_pgoff() Date: Fri, 4 Feb 2022 19:58:16 +0000 Message-Id: <20220204195852.1751729-40-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220204195852.1751729-1-willy@infradead.org> References: <20220204195852.1751729-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 1AB2740004 X-Rspam-User: nil Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=c0dzG4ll; dmarc=none; spf=none (imf27.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-Stat-Signature: sczp99tgc13cbow1efmwniobufbg4zny X-HE-Tag: 1644004747-382321 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: This is the folio equivalent of page_to_pgoff(). Signed-off-by: Matthew Wilcox (Oracle) --- include/linux/pagemap.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index cdb3f118603a..dddd660da24f 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -703,6 +703,17 @@ static inline loff_t folio_file_pos(struct folio *fo= lio) return page_file_offset(&folio->page); } =20 +/* + * Get the offset in PAGE_SIZE (even for hugetlb folios). + * (TODO: hugetlb folios should have ->index in PAGE_SIZE) + */ +static inline pgoff_t folio_pgoff(struct folio *folio) +{ + if (unlikely(folio_test_hugetlb(folio))) + return hugetlb_basepage_index(&folio->page); + return folio->index; +} + extern pgoff_t linear_hugepage_index(struct vm_area_struct *vma, unsigned long address); =20 --=20 2.34.1