All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Gow <davidgow@google.com>
To: Vincent Whitchurch <vincent.whitchurch@axis.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	Patricia Alfonso <trishalfonso@google.com>,
	Jeff Dike <jdike@addtoit.com>,
	Richard Weinberger <richard@nod.at>,
	anton.ivanov@cambridgegreys.com,
	Dmitry Vyukov <dvyukov@google.com>,
	Brendan Higgins <brendanhiggins@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: David Gow <davidgow@google.com>,
	kasan-dev <kasan-dev@googlegroups.com>,
	linux-um@lists.infradead.org, LKML <linux-kernel@vger.kernel.org>,
	Daniel Latypov <dlatypov@google.com>,
	linux-mm@kvack.org, kunit-dev@googlegroups.com
Subject: [PATCH v4 1/2] mm: Add PAGE_ALIGN_DOWN macro
Date: Thu, 30 Jun 2022 16:08:33 +0800	[thread overview]
Message-ID: <20220630080834.2742777-1-davidgow@google.com> (raw)

This is just the same as PAGE_ALIGN(), but rounds the address down, not
up.

Suggested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
---

Please take this patch as part of the UML tree, along with patch #2,
thanks!

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


_______________________________________________
linux-um mailing list
linux-um@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-um


WARNING: multiple messages have this Message-ID (diff)
From: David Gow <davidgow@google.com>
To: Vincent Whitchurch <vincent.whitchurch@axis.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	 Patricia Alfonso <trishalfonso@google.com>,
	Jeff Dike <jdike@addtoit.com>,
	 Richard Weinberger <richard@nod.at>,
	anton.ivanov@cambridgegreys.com,
	 Dmitry Vyukov <dvyukov@google.com>,
	Brendan Higgins <brendanhiggins@google.com>,
	 Andrew Morton <akpm@linux-foundation.org>,
	Andrey Konovalov <andreyknvl@gmail.com>,
	 Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: David Gow <davidgow@google.com>,
	kasan-dev <kasan-dev@googlegroups.com>,
	 linux-um@lists.infradead.org,
	LKML <linux-kernel@vger.kernel.org>,
	 Daniel Latypov <dlatypov@google.com>,
	linux-mm@kvack.org, kunit-dev@googlegroups.com
Subject: [PATCH v4 1/2] mm: Add PAGE_ALIGN_DOWN macro
Date: Thu, 30 Jun 2022 16:08:33 +0800	[thread overview]
Message-ID: <20220630080834.2742777-1-davidgow@google.com> (raw)

This is just the same as PAGE_ALIGN(), but rounds the address down, not
up.

Suggested-by: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Acked-by: Andrew Morton <akpm@linux-foundation.org>
---

Please take this patch as part of the UML tree, along with patch #2,
thanks!

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



             reply	other threads:[~2022-06-30  8:08 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-30  8:08 David Gow [this message]
2022-06-30  8:08 ` [PATCH v4 1/2] mm: Add PAGE_ALIGN_DOWN macro David Gow
2022-06-30  8:08 ` [PATCH v4 2/2] UML: add support for KASAN under x86_64 David Gow
2022-06-30  8:08   ` David Gow
2022-06-30  9:41   ` Dmitry Vyukov
2022-06-30  9:41     ` Dmitry Vyukov
2022-06-30 12:54     ` Vincent Whitchurch
2022-06-30 12:54       ` Vincent Whitchurch
2022-06-30 13:28       ` Andrey Konovalov
2022-06-30 13:28         ` Andrey Konovalov
2022-07-01  9:08         ` David Gow
2022-07-01  9:08           ` David Gow
2022-07-01  9:16           ` Vincent Whitchurch
2022-07-01  9:16             ` Vincent Whitchurch
2022-07-01  9:43             ` David Gow
2022-07-01  9:43               ` David Gow
2022-07-01 10:04               ` Vincent Whitchurch
2022-07-01 10:04                 ` Vincent Whitchurch
2022-07-01 10:34                 ` Dmitry Vyukov
2022-07-01 10:34                   ` Dmitry Vyukov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220630080834.2742777-1-davidgow@google.com \
    --to=davidgow@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=andreyknvl@gmail.com \
    --cc=anton.ivanov@cambridgegreys.com \
    --cc=brendanhiggins@google.com \
    --cc=dlatypov@google.com \
    --cc=dvyukov@google.com \
    --cc=jdike@addtoit.com \
    --cc=johannes@sipsolutions.net \
    --cc=kasan-dev@googlegroups.com \
    --cc=kunit-dev@googlegroups.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=linux-um@lists.infradead.org \
    --cc=richard@nod.at \
    --cc=ryabinin.a.a@gmail.com \
    --cc=trishalfonso@google.com \
    --cc=vincent.whitchurch@axis.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.