From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCF6C3C342B for ; Thu, 21 May 2026 11:33:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779363192; cv=none; b=Rz8u4pF3X5T3JBTTZ+T1KI0JtV09VTZcl5RQZ0QUo9615akGaalFQ2TlPzYWp20DZbSODMe8GXyNm1ig0SsM1n+ejAIrltOgl9JdwRUMmtc5oJErf7H/ekky8B/zt+n1788sDyV/WUHS8JP12Ezx/ypPm5eR2tIUCBvKFfVsOGc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779363192; c=relaxed/simple; bh=I40P2eSXRM2TuHzM3iOboWeRlEBUVQUHxeZfUeZmfHs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=C7XY5IDYppBw3Y1yKnpuc/vlvwaLHX/zbQC/NHgaJxASW7stcHTu5mL/ieth/V11oYLEpzbF/rk30ey1JTmCTq0jLCjp3xVUClvwgOrTY49nCiR7TGs3HVXWqJWxId5hWkXTbGr7lzFxpAo5wUB7CzCQOuCCNw3GvArtiVyPZoc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y2i+qr0I; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y2i+qr0I" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 706261F000E9; Thu, 21 May 2026 11:33:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1779363191; bh=l+EoXkJOHHaMKKCSNNSB1HDpDEcGyHnosLWxzIMLQDk=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=Y2i+qr0IFNR9/uegvvo7AbfD9Oarz3B9H8p6zfxJGzUAAqZzObOfSM2BZnf57qqBX HoOjNKOtqiWqoX67EKvVQaSB0Ia3hipJvcxR0DxASYaKbjxetBC/9lv+UEGWGm0u0J QuPOkmXLjqQ504QovaC7JfqQBQ1GrbFuWl+Aenf7srOqM4tTYesj1FHPo41OuU0LVD ffbdDP52nLULIySYUXjHw4Y9lTO7my4eUepC6Zl4dAZjZ5ecAk8ChKC7YtQfC0MOyI CeGeYnoBZQ7ldi4QCvqphJMs9lz6m33rCDXLcl4ONUgZ5CMYdj7AKmF86I9YRaVvgk 7w0G3OY0Yinsg== Date: Thu, 21 May 2026 12:33:05 +0100 From: Lorenzo Stoakes To: Thorsten Blum Cc: Andrew Morton , David Hildenbrand , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Andy Lutomirski , Thomas Gleixner , Vincenzo Frascino , Kees Cook , Andy Shevchenko , Yury Norov , David Laight , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2 0/2] mm/vdso: make offset_in_page() usable without linux/mm.h Message-ID: References: <20260521090655.160282-4-thorsten.blum@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20260521090655.160282-4-thorsten.blum@linux.dev> On Thu, May 21, 2026 at 11:06:56AM +0200, Thorsten Blum wrote: > offset_in_page() is a small page-arithmetic helper that has been around > for 20+ years. However, page-offset calculations are still open-coded in > many places and in different ways: > > (unsigned long)p & ~PAGE_MASK > (unsigned long)p & (PAGE_SIZE - 1) > (long)p & (PAGE_SIZE - 1) > ... > > Some of these open-coded instances may be due to offset_in_page() being > buried 3000+ lines into linux/mm.h; others may have avoided including > linux/mm.h, which is a large header that pulls in many others. This is good but I think you're still missing the 'why' here (as to why files don't import mm.h, and thus what this series addreses), which presumably, is compile time. > > Patch 1 moves offset_in_page() from linux/mm.h to vdso/page.h, which > keeps the helper with other low-level page definitions and allows users > that only need offset_in_page() to avoid including linux/mm.h. > > Patch 2 shows a concrete example where including vdso/page.h is > sufficient and including the large linux/mm.h would be unnecessary. > > Existing users of offset_in_page() do not need to change because patch 1 > also includes vdso/page.h from linux/mm.h. > > This series is based on akpm/mm.git mm-nonmm-unstable commit > d067a83c8063 ("string: use min in sized_strscpy"), which is also in > linux-next. > > Changes in v2: > - Add a cover letter and drop the bytes_to_page_end() helper > - Move offset_in_page() to vdso/page.h as suggested by David and Lorenzo > - Use offset_in_page() in lib/string.c as an example since > bitmap_print_to_pagebuf() in lib/bitmap-str.c is being removed [1] > - v1: https://lore.kernel.org/lkml/20260517123428.1181981-4-thorsten.blum@linux.dev/ > > [1] https://lore.kernel.org/lkml/20260519163058.953690-3-ynorov@nvidia.com/ > --- > Thorsten Blum (2): > vdso: move offset_in_page() from linux/mm.h to vdso/page.h > string: use offset_in_page() in sized_strscpy() > > include/linux/mm.h | 2 +- > include/vdso/page.h | 2 ++ > lib/string.c | 3 ++- > 3 files changed, 5 insertions(+), 2 deletions(-) > > > base-commit: d067a83c8063d1bdcbd9af8e1326d846f85138b8