From patchwork Mon Jan 30 21:43:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13121905 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 63D67C54EAA for ; Mon, 30 Jan 2023 21:44:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F288D6B0073; Mon, 30 Jan 2023 16:43:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EB11A6B0074; Mon, 30 Jan 2023 16:43:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF06C6B0075; Mon, 30 Jan 2023 16:43:59 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id A22E16B0073 for ; Mon, 30 Jan 2023 16:43:59 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 55B62802BA for ; Mon, 30 Jan 2023 21:43:59 +0000 (UTC) X-FDA: 80412793398.24.59591EA Received: from mail-pj1-f53.google.com (mail-pj1-f53.google.com [209.85.216.53]) by imf30.hostedemail.com (Postfix) with ESMTP id 6644780020 for ; Mon, 30 Jan 2023 21:43:57 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PBaFoOSG; spf=pass (imf30.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1675115037; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ediNP9jmTx5MiZXyPNx7A5RKRq6cvf2YdQqsm1ekQJg=; b=uYTJdrHS18kThMB3u8baJ4uBFR1HyUPx+Rqut74dLJX/bxHN4r+IIygmG6sKQrXZ5OFnLj FmywQ3Gpl1TNU32r1drLWWHuoOgo5HlV24g6Ap3rBPQR4KUgNye16OXOpyxT5Ijo39UKI0 V/rC9gTN3q2ZAOcoOCT63DXP2pZekYc= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=PBaFoOSG; spf=pass (imf30.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.216.53 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1675115037; a=rsa-sha256; cv=none; b=LfXUbAn/m6dTAi/0m4vd+IvbKUV3h4ghY3KLrPMiMpVJumeK1vA/smvMotC8nE/QEnpXfL SPy1ouoTaOsxDS1M92wwbG6a0Ha1VsfLtjXidcw4BiaBXkk4lgO/5GhTQlPeVe/MAfj7Df BJz7un5I8Lnq0/49aJe/Ug/4zUVzu2k= Received: by mail-pj1-f53.google.com with SMTP id nm12-20020a17090b19cc00b0022c2155cc0bso12457313pjb.4 for ; Mon, 30 Jan 2023 13:43:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ediNP9jmTx5MiZXyPNx7A5RKRq6cvf2YdQqsm1ekQJg=; b=PBaFoOSG+jh+Xjk4yu5k0mclCq95zVowkLwfwnozwaJGsZ7dJuUO+HAwSj2CnMiWu2 04OjiWdzrsGfsiNhiAN8aI91IRKA+6362I3k3iKQYr21do8lFKqzPXLqL6iPOJSxvDm8 ESs/tnac1+S84ztkx0YgGN0x3NIN3ai8D6zq2CVxcbmdeK2SmbKzjLD3nVv4XyHiLp3z BA+QOsuRp7JdeNdp8HrY1T1o3fGUajdyiy9WJdxE66pg9lzEfEmcADYX3qVB7MkJcotn TkujXEQLlM/xDXB9oy/BbqiTPHEbCAbrHMBDu37iilqmoWmBkMcRcAOTM5RKP4Qzejlk Q9zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ediNP9jmTx5MiZXyPNx7A5RKRq6cvf2YdQqsm1ekQJg=; b=nsy+jm0LI5Sj+VOMRzUXs5I53CRGftvb58kRlafk71D9kbinNpfSXylgMm+jQP960h p/oTmpyTcQayu5QBwe9lB8+lePah0y1tqOc4ckUX7SCDq3ntwciWztyEzPoxlreKivvK XO03a4p5e6va+MdjeWfien8Xz5h+EgOgb/cQWNtn3nbENz36HkaXnHCGAUspcA+UAWlK VWeH1VonhAqeyVXCQMA5jEQmnU7xx1BUdLWs8voN28wsEcljIzgl6AnuJgJ8J2Qnkb6y BaNXJXjYEXMCN26PFvRLru02tr7pra2Y9CVj7EBeHHnNuqJ+lOYeLLScCrM3O5cHlUNB hJsg== X-Gm-Message-State: AO0yUKWTrwdw1zAJui6cAxSrNF+V8ApiOfnPwxaNlRAi7ZYAc6Tn8rNg cvTPdZvdhNBNk1/7/QWLPYKG771eER0= X-Google-Smtp-Source: AK7set+vv9jj+URyyrDpX/kMFZKfmRfYhOWM9Dd+Bv8gep0RDdihfzO4kLqoGfEgi8XlOrozIiYlmw== X-Received: by 2002:a17:90b:1a92:b0:22c:d57:519f with SMTP id ng18-20020a17090b1a9200b0022c0d57519fmr10945094pjb.34.1675115036137; Mon, 30 Jan 2023 13:43:56 -0800 (PST) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::a8cd]) by smtp.googlemail.com with ESMTPSA id d5-20020a17090a628500b0022bbad75af6sm25156403pjj.1.2023.01.30.13.43.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Jan 2023 13:43:55 -0800 (PST) From: "Vishal Moola (Oracle)" To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, willy@infradead.org, linux-kernel@vger.kernel.org, "Vishal Moola (Oracle)" Subject: [PATCH mm-unstable v2 1/4] mm: Add folio_get_nontail_page() Date: Mon, 30 Jan 2023 13:43:49 -0800 Message-Id: <20230130214352.40538-2-vishal.moola@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230130214352.40538-1-vishal.moola@gmail.com> References: <20230130214352.40538-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 6644780020 X-Rspam-User: X-Stat-Signature: d7xzajujhx45ce6t3rwr3fo5jtgrrfyn X-HE-Tag: 1675115037-610854 X-HE-Meta: U2FsdGVkX189sWhVJ9xoEIlyor4FXlGI+/CGEfjiKCcYow4MgCASP46Gvayyf6HBSGD93vB5+HiVQj/SyipCAFUY1IU2znpi5zEApZbBV/58gV5wxuTUq3N+DkfCBfH7dTog54JjDIhbiawenib2g3dbwMJM1NhBOE/SwiRLFw60xUgrsD51BBbtMWUYyDAjMKjofz572RVDSn8CmF/hcXjSspW3Umn2Jaud8Du39uNuQUfH3uxcqDI1I9PAKHxEIdcFWEjpiM0EKXu4LaonI5WLt7xUmbusIg/LTETuoe1XKj4eCj+deMvg/02nHN1D9m+aXV/njm1RqgzVdGiP9Y2bucfhT5KJ/pWq+iT+FChQLC9x8CQpUC0lzioHKq2eMbN+BVizgwRw9f2VGk9sRd6IxnP/wdu2bO08z8SZCVGWd1xoKTzkzFnOBFBFeSBRmQ06gd5gEDYFN/g8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cK7jDQ30ZeJDk5Hw90DcoTCkWsyfL2qN+QkZXubcgJKA== 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: folio_get_nontail_page() returns the folio associated with a head page. This is necessary for folio conversions where the behavior of that function differs between head pages and tail pages. Signed-off-by: Vishal Moola (Oracle) --- include/linux/mm.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index dd295c020e85..5da260346406 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -879,6 +879,13 @@ static inline bool get_page_unless_zero(struct page *page) return page_ref_add_unless(page, 1, 0); } +static inline struct folio *folio_get_nontail_page(struct page *page) +{ + if (unlikely(!get_page_unless_zero(page))) + return NULL; + return (struct folio *)page; +} + extern int page_is_ram(unsigned long pfn); enum {