From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-172.mta0.migadu.com (out-172.mta0.migadu.com [91.218.175.172]) (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 DE1D12DC79B for ; Thu, 21 May 2026 09:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779354455; cv=none; b=M6zpIuCROsAc0kpOlaI/B7ophEgDaU13XqrSd3X+IQQZvN45QCb7wbCvkHlvcetzsUljjwPc4XSx2n1i4HgwDoXbDH5lVl3Da8HZ6Qfwu6wLbaWB06Xkd6th2ThfdS9WvO3TfNj6tBazt4rPPDp04YXaCGUKB7ykwPsO96lNvL0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1779354455; c=relaxed/simple; bh=YgA0bvDDsg2aT23TUlbqLxOb60JWbCeIkZgzZ8KQBHk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=ttmLjkUFjZEQaOho9HsFqR7gsgGx0tM8rgbi0Ce3Lf9+C5X7KTin1rZNh/6KcGlFm7IVnrztGdSRLFNB1KySlCIJrNq76ZtKQlI3YBqMvEG9MjKE4fUZn6zyMBUxCs6eV/cxb2gLwxluNmdksX57a5C7PjzsBtp6VhTk04m25WI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=vFui4xFd; arc=none smtp.client-ip=91.218.175.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="vFui4xFd" X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1779354450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=3/utW7ixOXqEKWPMA0wnZDzgH8XeOxNri1fubQ6qmsY=; b=vFui4xFdv/MVk94/qJvKag4tiAguASd2cIasBMA55++kaWuLrcPoBd/gbpre2QokBeEHKJ GjcE/ixsBPRTMaR1dpZBsYwhhylp/J6fEnR2JIRp40u1gxMEdy5y6pIEm0f81GJbVCajSE mi/pCTVR4K4Ve1TxvPfJm3hDXA3KJoE= From: Thorsten Blum To: Andrew Morton , David Hildenbrand , Lorenzo Stoakes , "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 Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Thorsten Blum Subject: [PATCH v2 0/2] mm/vdso: make offset_in_page() usable without linux/mm.h Date: Thu, 21 May 2026 11:06:56 +0200 Message-ID: <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 X-Developer-Signature: v=1; a=openpgp-sha256; l=1896; i=thorsten.blum@linux.dev; h=from:subject; bh=YgA0bvDDsg2aT23TUlbqLxOb60JWbCeIkZgzZ8KQBHk=; b=owGbwMvMwCUWt7pQ4caZUj3G02pJDFl8p/X5V63aEiF+L/XRldluVhPa/nbejix8udki6t2x0 oYT83JPd5SyMIhxMciKKbI8mPVjhm9pTeUmk4idMHNYmUCGMHBxCsBEZKsZ/geE3BT6lGzxOCn8 W8NC70N/hbNlfjcE6WQuypBNF1vAEc7wT0O9J1bl1dMU/UcMcTPmWEg+v1q27H21iuymsCr3dvv 9jAA= X-Developer-Key: i=thorsten.blum@linux.dev; a=openpgp; fpr=1D60735E8AEF3BE473B69D84733678FD8DFEEAD4 Content-Transfer-Encoding: 8bit X-Migadu-Flow: FLOW_OUT 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. 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