From patchwork Fri May 27 18:55:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Gow X-Patchwork-Id: 12863692 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 308C4C433F5 for ; Fri, 27 May 2022 18:56:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A03658D0003; Fri, 27 May 2022 14:56:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9B2A28D0001; Fri, 27 May 2022 14:56:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 874288D0003; Fri, 27 May 2022 14:56:08 -0400 (EDT) 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 78E2F8D0001 for ; Fri, 27 May 2022 14:56:08 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id 4371C809D1 for ; Fri, 27 May 2022 18:56:08 +0000 (UTC) X-FDA: 79512428016.19.12961E6 Received: from mail-yb1-f201.google.com (mail-yb1-f201.google.com [209.85.219.201]) by imf10.hostedemail.com (Postfix) with ESMTP id C1E7BC0041 for ; Fri, 27 May 2022 18:55:28 +0000 (UTC) Received: by mail-yb1-f201.google.com with SMTP id 82-20020a250255000000b0065a58668d5dso2815943ybc.0 for ; Fri, 27 May 2022 11:56:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:message-id:mime-version:subject:from:to:cc; bh=342jTvfgyTJ/fKu8Bj0JFN4DakYoNTyydnegV/i2TgI=; b=PYF1hpmpeKbQiDJ/Giw7g7NYnRSZrSPt/VlmV/6M4r4b+0XL11D1xYacFWIZqvAtBQ vHSmkE0rFQ7KBxsBOjVKZCqLFqjc+J5rJPdw0Jbu4PbCZNQl5/3g5LZG3igketLFOd7D X2ZXrF/tVd9fODrr0L3cZhFZauOVLuGN0QGLV6d2ui+IHO/pBKWqNY8ZqDaU20S2hAIM R0dLzRzLLq0/dcasaM8x3vRAJuf1qpiGoVRP0HIyRNW5FyKkVCcelzEbvbHXIX66MRzw NynXbaVdI/lNEgbxseGDoKyrMn2BVsaQXBTlW9vyUJRDtF0+apPC4BMnyDzI49cJuvhH NJWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:message-id:mime-version:subject:from:to:cc; bh=342jTvfgyTJ/fKu8Bj0JFN4DakYoNTyydnegV/i2TgI=; b=NkBYCKY5KNL8hHQAxWiSVyavb/Yw+vS2XoNUjpHyUDoZ1/rCvKO317glFaOOc9FXMn g3+jFDEm7EVYI0nUozL4GN5jwgOKwNOcm5dzd5CRqznCmaLw95liJCVk+HiMX2viDNG2 BMuGniyyBf82FeafD+LB6ogy14LgIQ/UsK+kyVS8wC/7zgvXuy7h9anXP50ooUPQup01 6FIDYx+cjYNzgZ6FBo3x+YUaKdwMu/IaUop8qxvT8Ig3LllLzVPBdhnqx9OKwCo/plHd CidhMXDFYiGbJM5tmZ0WSM/6PDieJ5k9wf2408fMujN8ugus4nLY0f4OXoUZGmyacNtm H+Yw== X-Gm-Message-State: AOAM530VM78nKDn0LCZjj88Yn0G4rgWwshgzCahEsPzvcCUqvWYkJr2e Qg2MqAxgP+Fd7k9hv/Pvjdjw12ZMn9R6Dw== X-Google-Smtp-Source: ABdhPJz/QBLvmoj2qBlJY5WE42RVyqoRYZSp2QGQ5nHYPaFHzDB2qiRgsV/jwMBxoLb0CkvVpPclZj6wMdcAxg== X-Received: from spirogrip.svl.corp.google.com ([2620:15c:2cb:201:122e:1813:2b92:fe8e]) (user=davidgow job=sendgmr) by 2002:a25:9742:0:b0:64e:2c40:b33e with SMTP id h2-20020a259742000000b0064e2c40b33emr41935567ybo.455.1653677767170; Fri, 27 May 2022 11:56:07 -0700 (PDT) Date: Fri, 27 May 2022 11:55:59 -0700 Message-Id: <20220527185600.1236769-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.36.1.124.g0e6072fb45-goog Subject: [PATCH v2 1/2] mm: Add PAGE_ALIGN_DOWN macro From: David Gow To: Vincent Whitchurch , Johannes Berg , Patricia Alfonso , Jeff Dike , Richard Weinberger , anton.ivanov@cambridgegreys.com, Dmitry Vyukov , Brendan Higgins , Andrew Morton , Andrey Konovalov , Andrey Ryabinin Cc: David Gow , kasan-dev , linux-um@lists.infradead.org, LKML , Daniel Latypov , linux-mm@kvack.org X-Rspam-User: X-Rspamd-Queue-Id: C1E7BC0041 X-Stat-Signature: mc7u6p341rzaomxn8xsgux549b3wbwhh Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=PYF1hpmp; spf=pass (imf10.hostedemail.com: domain of 3xx6RYggKCGQFCXKFIQYIQQING.EQONKPWZ-OOMXCEM.QTI@flex--davidgow.bounces.google.com designates 209.85.219.201 as permitted sender) smtp.mailfrom=3xx6RYggKCGQFCXKFIQYIQQING.EQONKPWZ-OOMXCEM.QTI@flex--davidgow.bounces.google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam09 X-HE-Tag: 1653677728-709612 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 just the same as PAGE_ALIGN(), but rounds the address down, not up. Suggested-by: Dmitry Vyukov Signed-off-by: David Gow Acked-by: Andrew Morton --- Note: there is no v1 of this patch, it's just part of v2 of the UML/KASAN series. There are almost certainly lots of places where this macro should be used: just look for ALIGN_DOWN(..., PAGE_SIZE). I haven't gone through to try to replace them all. --- include/linux/mm.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/linux/mm.h b/include/linux/mm.h index e34edb775334..e68731f0ef20 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -221,6 +221,9 @@ int overcommit_policy_handler(struct ctl_table *, int, void *, size_t *, /* to align the pointer to the (next) page boundary */ #define PAGE_ALIGN(addr) ALIGN(addr, PAGE_SIZE) +/* to align the pointer to the (prev) page boundary */ +#define PAGE_ALIGN_DOWN(addr) ALIGN_DOWN(addr, PAGE_SIZE) + /* test whether an address (unsigned long or pointer) is aligned to PAGE_SIZE */ #define PAGE_ALIGNED(addr) IS_ALIGNED((unsigned long)(addr), PAGE_SIZE)