Received: by 2002:ac0:c50a:0:0:0:0:0 with SMTP id y10csp1074469imi; Fri, 1 Jul 2022 02:29:37 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tUbsfW+tmFWOC3OowYAcuIfyFzp6Tvz1uVE9lx4M5pv0AervFHBbR5ZpgoFhmPn9nhQ+77 X-Received: by 2002:a17:906:38ca:b0:722:e836:1d85 with SMTP id r10-20020a17090638ca00b00722e8361d85mr13150072ejd.194.1656667777399; Fri, 01 Jul 2022 02:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1656667777; cv=none; d=google.com; s=arc-20160816; b=bZnYLD8TPm4jMfCS3cgCkb9YLRalxxo/6npbQagF1ee3AaOmO5WixkSrfva4kwPB5R Q48DXnHMQwdZHBcFqfEWJXyLr6J5zQGcbcOYIXY6DqFw7PpC9mufdJXy9rg90rEhg3/n 7GtuhR5EL/potdIKhHskBLqMWbGLQo0X9867xYIq6m7zw8MX5b+oOwgLvZQNwhrqAeBq HpvD29zHDn6RxRpaHObMgcoD+F//8eHPCMIHkkHegdG98N9CGAR/4OTHh5Y1EnnNXUoX h7x/GVwxrGMUmWr++o7ZzVHV3pgoGiW6lddJeP/4f00MtDDZYAL68jWXB5ld97JeOSxk IjNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:mime-version:message-id:date :dkim-signature; bh=Gzf9MNYfzuExJ4letAUuWlfZz/ymERxaYUyT/EuC1fc=; b=COvihdbGxUvUPrdc3M645COqhaauyWNdLiwm5S1LZan0EauwG8GymwcLIl0jA6gVRx xgTKel4YZfZJFOVSPYjU/XA0deFRMfxOTlhhZKM6SwMzbo5cuzS+dR8+4AjeBQDuQnoC 3HFrpEYWhvSe+lX00WRDbeJO7k9NYhBqJ4Z5lyrl16U/JLiLO2LC6ga7X5DCCKyYwokE gZwnlw0dXTsrR2sw46q9l35ogtiav/IfcIBlyApngzox4HS32lHsR599hANAHY2BsQwR Pk2/G2X6XFrRP/jeoZ8u2nxYmTwgxfYzxDk5wt32Jt0psnXrJBxWhiq5u7O1FlFiWgV9 KDdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Ziw2qAXA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e17-20020a17090658d100b00726ed232bebsi532562ejs.630.2022.07.01.02.29.11; Fri, 01 Jul 2022 02:29:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=Ziw2qAXA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232764AbiGAJQ3 (ORCPT + 99 others); Fri, 1 Jul 2022 05:16:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232001AbiGAJQ1 (ORCPT ); Fri, 1 Jul 2022 05:16:27 -0400 Received: from mail-pj1-x104a.google.com (mail-pj1-x104a.google.com [IPv6:2607:f8b0:4864:20::104a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2633E4507B for ; Fri, 1 Jul 2022 02:16:27 -0700 (PDT) Received: by mail-pj1-x104a.google.com with SMTP id cp20-20020a17090afb9400b001ec75748019so1101614pjb.6 for ; Fri, 01 Jul 2022 02:16:27 -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=Gzf9MNYfzuExJ4letAUuWlfZz/ymERxaYUyT/EuC1fc=; b=Ziw2qAXAlzhNlbhTjbP0JE77DsFllvjUC3AvzRFw4OJ8KKLOHiNYxCskVSDnjCrbmk dRi/Tm4oQcCNrIY5p5Ziht1qS27pnUQatjR262bXMIcKV9YxIj2b/0029BocKRRLJlYU HP6zwkl7J2Icx8KXYVj+zvrUrOD58dKKWVnJye31y9E4/J2F4wUXrxoAQ4WcoSR7evCz ZSbWZjPy6gy16w95t0NfHgdbfNUgudhTVrD7nIgjoc8Kl8jNzBjvQSMW/2/0mC5xaqQu Wao9C47Jn/85zScpvweq1xtOni7nOQTixCgarYqulfUgkf2NQQ33BTBk593QPAqQQhv9 cLYQ== 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=Gzf9MNYfzuExJ4letAUuWlfZz/ymERxaYUyT/EuC1fc=; b=e60Dvfn0cGxnIznn3mgktdhTKmoQlQfRoEZECo+4PHFtjFttT8FUmskbu0r7vc5TPI CIiAPOTcnOIEKLua7I248WdicHaFtdxlGZzZtjiFzb9ntYCrBAqOsjN50LGh9PiS83PT dNsdMWdhp+3uBDvN9txE1Tbi/7hAMG4Y1fwNfgLQCCM61rqiOROsx0jco4HMatWE1IWq 5UNqQzWIXiU34qzQ39+Z+cCOrGjxQ3GU0YSuJP4CHP6B5WTWUESV49pILSABKrFSzm+g VdalXqkLYJp3T/12mnO/q3pKTLWu+qnPzM5TiRF9H4EuAWYv4J5XScvQOIXy32b51OK1 yf+g== X-Gm-Message-State: AJIora+g802i7yX5r+hIXPlyzGXgrrwLd4lU0bCj9i6I7RYGuG+NTU0r M759iTZGaVM+dKXMag5WT44BQhCdOyJfNQ== X-Received: from slicestar.c.googlers.com ([fda3:e722:ac3:cc00:4f:4b78:c0a8:20a1]) (user=davidgow job=sendgmr) by 2002:a17:90b:4a42:b0:1ec:adee:e298 with SMTP id lb2-20020a17090b4a4200b001ecadeee298mr17874949pjb.161.1656666986727; Fri, 01 Jul 2022 02:16:26 -0700 (PDT) Date: Fri, 1 Jul 2022 17:16:19 +0800 Message-Id: <20220701091621.3022368-1-davidgow@google.com> Mime-Version: 1.0 X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [PATCH v5 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, kunit-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- Please take this patch as part of the UML tree, along with patch #2, thanks! No changes to this patch since v4: https://lore.kernel.org/lkml/20220630080834.2742777-1-davidgow@google.com/ No changes to this patch since v3 (just a minor issue with patch #2): https://lore.kernel.org/lkml/20220630074757.2739000-1-davidgow@google.com/ Changes since v2: https://lore.kernel.org/lkml/20220527185600.1236769-1-davidgow@google.com/ - Add Andrew's Acked-by tag. v2 was the first version of this patch (it having been introduced as 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 9f44254af8ce..9abe5975ad11 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) -- 2.37.0.rc0.161.g10f37bed90-goog