From patchwork Tue Jun 4 09:08:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 13684920 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 6522CC27C50 for ; Tue, 4 Jun 2024 09:09:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4EE266B00A0; Tue, 4 Jun 2024 05:09:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 49BEF6B00A1; Tue, 4 Jun 2024 05:09:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 314E46B00A2; Tue, 4 Jun 2024 05:09:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 10ABC6B00A0 for ; Tue, 4 Jun 2024 05:09:20 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id C8956A0968 for ; Tue, 4 Jun 2024 09:09:19 +0000 (UTC) X-FDA: 82192632438.03.93FEB0A Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) by imf11.hostedemail.com (Postfix) with ESMTP id E6B3F40010 for ; Tue, 4 Jun 2024 09:09:17 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=AX5pF3Xy; spf=pass (imf11.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1717492158; 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=qOL4vXuZ0a4PoiG22TiWEmdORRFE9U+5xK6xKS6y2zU=; b=rUne1t5747jRQh5+vd+91XL47n9VZxQhMrOpwji8cOcfrvPuqSvH+nBIczl2tvhQ2Z/DQ+ bHLzmj4ZbyvXy63d7Yi9xrIyd0LHYaL8hp1IrU8EYmaCB5PkSVLVZQLdCfDNw7wRXUey2w KRC9WTvqQEouAk2jzi6lOoxB6TWsyNI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1717492158; a=rsa-sha256; cv=none; b=HMReo6J/Ig8Bwr4iMwRhiaMZ1Hq9o2XCS2qRrOcAVXQWE/66tHJRnEHybljfX92q+44gjU T+uMMRij/XtEY1C1LGP5vpGFqQdsoV5na5Ko7+w3d9cVmknBFwSYeKbsmcA1FvmOhMDgAP aQyGdB/OTqlVv5YJp2ps+ohN+kzqx4k= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=ionos.com header.s=google header.b=AX5pF3Xy; spf=pass (imf11.hostedemail.com: domain of max.kellermann@ionos.com designates 209.85.208.54 as permitted sender) smtp.mailfrom=max.kellermann@ionos.com; dmarc=pass (policy=quarantine) header.from=ionos.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-57a50fecbadso3146617a12.3 for ; Tue, 04 Jun 2024 02:09:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1717492156; x=1718096956; darn=kvack.org; 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=qOL4vXuZ0a4PoiG22TiWEmdORRFE9U+5xK6xKS6y2zU=; b=AX5pF3XyK7LKmQX4cgPml7K6YTGE82C9UE2XgK0emH6B7p2qMBd2P4DtMF7eHf6/hD l9KuRRkHxFJXgvjjdYFQZwOWq0X0AGvvlihk32RxvBraeRNvNDa1bnxON0O9Zv2me1lu aDbwaWouflNWlzPky4jr+UMV+1vbQusgNMedOepBiuRHaYedSmSQ1pYU7woP6nSPDk0Y jQyyVx5IfC6EOpUvRmgaRfym1FUlu+e3xQW9PDVhPZCkccB7cPs8OKXVnn0NHRua2jkJ udv3woN+dfHDo2LAAKiu83vG+qgLE/Xwnqq3CLzt/Fr5pBgptzeheULX3+m8KHHI7LKl 2MTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717492156; x=1718096956; 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=qOL4vXuZ0a4PoiG22TiWEmdORRFE9U+5xK6xKS6y2zU=; b=N1AJ3Y+xWYeLivBG+TxyrQuOMbFJEuGfiMM6kuGa3wNEq4acbUycbjDCRHirAW36cf 6yeN1d+Lnecw+6uRkn6H0qfO14hT4hdmRP2eqwDJIm9U51J+l4ShfUrF2cz6TPJ5vCJB xJbiZ3NPpbSu5JOdjRbgRjakoEbytirjKNRtTeZQr9P5DSdw72XoMmy1XGqFFAhAzQCY 0obxr0n//lc+LPG71AKs20iFo32R+rhrH0b3hf/NEdk8R/Qe76iEGSpvBg1XOAi4qI8h Z7t+NpYlI02sFUaQmdUuXaZPYHC3Efdsuo5zJ5ur4AE0t8IwakY2by50b+AZaiLOZK+5 K14w== X-Forwarded-Encrypted: i=1; AJvYcCUKQUO6XawamWCouKkxJUQAgGEjxX8iEV9unRNt6zfmLoIX3/Ase4EEydDUPgYvKE62pABZ42telxlyj6k8FVxu8QI= X-Gm-Message-State: AOJu0YxQ5mX6MuczcWyaoDUJfvuj9QAkW6/WwNbRyUrhhdK0K9Mk1EMo VcHi1eUTmo6xmmbh5curybyNRsEhlJVTmAlYeCUOTzwLXrGK0mUeTOlN3M65dfs= X-Google-Smtp-Source: AGHT+IHt9F2oYYdhVTvxemPiWIf8QKaB1WXTbOFaVE7w6l+bxeSDT0tJO0j/hkCZ7p0XgmZYIYi9Bw== X-Received: by 2002:a17:906:6bc4:b0:a68:d2c:2a23 with SMTP id a640c23a62f3a-a6822049940mr757127166b.76.1717492156465; Tue, 04 Jun 2024 02:09:16 -0700 (PDT) Received: from raven.blarg.de (p200300dc6f4f9200023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f4f:9200:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a68fa49e66fsm328376766b.129.2024.06.04.02.09.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 02:09:15 -0700 (PDT) From: Max Kellermann To: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: willy@infradead.org, sfr@canb.auug.org.au, david@redhat.com, Max Kellermann Subject: [PATCH v6 08/15] linux/mm.h: move folio_next() to mm/folio_next.h Date: Tue, 4 Jun 2024 11:08:38 +0200 Message-Id: <20240604090845.2182265-9-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240604090845.2182265-1-max.kellermann@ionos.com> References: <20240604090845.2182265-1-max.kellermann@ionos.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: z5b6f957k494hg8fgd4cuhcjnsz49dr4 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E6B3F40010 X-HE-Tag: 1717492157-602857 X-HE-Meta: U2FsdGVkX19mMi1tpM/d7NVAW0MvuMv1UeTku0SU+8I1Btn0ul209KPjUmkMsUPeCvQHz3dSiJgEbLflOTyUE0Wt2se3ewOf/CaiYJzYwumzB2F8gfvRXTjPEJ5O0aOOZQBH3S9NbOadSwy1w37ByueMzu7wst9XOemSfVBPQyyKoRzpPc98ZhSBnCkW7RW4sm07T87D5njTKaahpNK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eZbur+6EG/pszLIptleNIg5bZWS/B4Kh5oSZ8P9KtP9LS3KM7IX/vO6fPr4uG3hENdrHGvwVKji4ZI9+TW0ma231XV+8v5WHttwLcD3wnRENpT81Phe62zOB258MHe9bKtQmf3J8+pxpSrHvoNMHF7nyFCwNpmvO8KxVH5gVkxcpQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000017, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Prepare to reduce dependencies on linux/mm.h. folio_next() is used by linux/bio.h. Moving it to a separate lean header will allow us to avoid the dependency on linux/mm.h. Having a one-function header may seem excessive, but there is hardly another way if we want to distangle linux/mm.h from linux/bio.h. If one day, say, folio_prev() gets added, we can still rename the header to something like folio_iterator.h, but until that happens, this folio_next.h header seems like the best trade-off to reduce dependencies. Signed-off-by: Max Kellermann --- include/linux/mm.h | 20 +------------------- include/linux/mm/folio_next.h | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 19 deletions(-) create mode 100644 include/linux/mm/folio_next.h diff --git a/include/linux/mm.h b/include/linux/mm.h index b11bbbdd2754..7be75960e7e1 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2,6 +2,7 @@ #ifndef _LINUX_MM_H #define _LINUX_MM_H +#include #include #include #include @@ -1916,25 +1917,6 @@ static inline void set_page_links(struct page *page, enum zone_type zone, #define MAX_FOLIO_NR_PAGES MAX_ORDER_NR_PAGES #endif -/** - * folio_next - Move to the next physical folio. - * @folio: The folio we're currently operating on. - * - * If you have physically contiguous memory which may span more than - * one folio (eg a &struct bio_vec), use this function to move from one - * folio to the next. Do not use it if the memory is only virtually - * contiguous as the folios are almost certainly not adjacent to each - * other. This is the folio equivalent to writing ``page++``. - * - * Context: We assume that the folios are refcounted and/or locked at a - * higher level and do not adjust the reference counts. - * Return: The next struct folio. - */ -static inline struct folio *folio_next(struct folio *folio) -{ - return (struct folio *)folio_page(folio, folio_nr_pages(folio)); -} - /** * folio_likely_mapped_shared - Estimate if the folio is mapped into the page * tables of more than one MM diff --git a/include/linux/mm/folio_next.h b/include/linux/mm/folio_next.h new file mode 100644 index 000000000000..7016e303439c --- /dev/null +++ b/include/linux/mm/folio_next.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_MM_FOLIO_NEXT_H +#define _LINUX_MM_FOLIO_NEXT_H + +#include // for folio_nr_pages() +#include // for nth_page(), needed by folio_page() + +/** + * folio_next - Move to the next physical folio. + * @folio: The folio we're currently operating on. + * + * If you have physically contiguous memory which may span more than + * one folio (eg a &struct bio_vec), use this function to move from one + * folio to the next. Do not use it if the memory is only virtually + * contiguous as the folios are almost certainly not adjacent to each + * other. This is the folio equivalent to writing ``page++``. + * + * Context: We assume that the folios are refcounted and/or locked at a + * higher level and do not adjust the reference counts. + * Return: The next struct folio. + */ +static inline struct folio *folio_next(struct folio *folio) +{ + return (struct folio *)folio_page(folio, folio_nr_pages(folio)); +} + +#endif /* _LINUX_MM_FOLIO_NEXT_H */