diff for duplicates of <20100709225814.855827624@efficios.com> diff --git a/a/1.txt b/N1/1.txt index 14b830d..bda85db 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1,3 +1,170 @@ -An embedded and charset-unspecified text was scrubbed... -Name: create-generic-alignment-api.patch -URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100709/c715dd62/attachment.ksh> +Rather than re-doing the "alignment on a type size" trick all over again at +different levels, import the "ltt_align" from LTTng into kernel.h and make this +available to everyone. Renaming to: + +- object_align() +- object_align_floor() +- offset_align() +- offset_align_floor() + +Changelog since v7: +- Add missing include/linux/Kconfig header-y. + +Changelog since v6: +- Adapt to changes introduced by + commit a79ff731a1b277d0e92d9453bdf374e04cec717a +- Use __alignof__() instead of sizeof() to support compound types. + +Changelog since v5: +- moved alignment apis to a separate header file so that it is possible + to use them from other header files which are, for example, included + from kernel.h. + +Changelog since v4: +- add missing ( ) around parameters within object_align() and + object_align_floor(). +- More coding style cleanups to ALIGN() (checkpatch.pl is happy now). + +Changelog since v3: +- optimize object_align*() so fewer instructions are needed for alignment of + addresses known dynamically. Use the (already existing) "ALIGN()", and create + the "ALIGN_FLOOR()" macro. +- While we are there, let's clean up the ALIGN() macros wrt coding style. e.g. + missing parenthesis around the first use of the "x" parameter in ALIGN(). + +Changelog since v2: +- Fix object_align*(): should use object size alignment, not pointer alignment. + +Changelog since v1: +- Align on the object natural alignment + (rather than min(arch word alignment, natural alignment)) + +The advantage of separating the API in "object alignment" and "offset alignment" +is that it gives more freedom to play with offset alignment. Very useful to +implement a tracer ring-buffer alignment. (hint hint) + +Typical users will use "object alignment", but infrastructures like tracers +which need to perform alignment of statically known base+offsets will typically +use "offset alignment", because it allows to align with respect to a base rather +than to pass an absolute address. + +We use "sizeof(object)" rather than "__alignof__()" object because alignof +returns "recommended" object alignment for the architecture, which can be +sub-optimal on some architectures. By ensuring alignment on the object size, we +are sure to make the right choice. + +Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> +Signed-off-by: Alexander Shishkin <virtuoso@slind.org> +CC: Russell King - ARM Linux <linux@arm.linux.org.uk> +CC: linux-arm-kernel@lists.infradead.org +CC: Imre Deak <imre.deak@nokia.com> +CC: Jamie Lokier <jamie@shareable.org> +CC: rostedt@goodmis.org +CC: mingo@elte.hu +CC: Alexey Dobriyan <adobriyan@gmail.com> +--- + include/linux/Kbuild | 1 + include/linux/align.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++ + include/linux/kernel.h | 8 ------- + 3 files changed, 58 insertions(+), 7 deletions(-) + create mode 100644 include/linux/align.h + +Index: linux.trees.git/include/linux/align.h +=================================================================== +--- /dev/null 1970-01-01 00:00:00.000000000 +0000 ++++ linux.trees.git/include/linux/align.h 2010-07-01 11:54:43.000000000 -0400 +@@ -0,0 +1,56 @@ ++#ifndef _LINUX_ALIGN_H ++#define _LINUX_ALIGN_H ++ ++#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK((x), (typeof(x))(a) - 1) ++#define __ALIGN_KERNEL_MASK(x, mask) \ ++ (((x) + (mask)) & ~(mask)) ++ ++#ifdef __KERNEL__ ++ ++#include <linux/types.h> ++ ++#define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) ++#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) ++#define PTR_ALIGN(p, a) ((typeof(p)) ALIGN((unsigned long) (p), (a))) ++#define ALIGN_FLOOR(x, a) __ALIGN_FLOOR_MASK((x), (typeof(x)) (a) - 1) ++#define __ALIGN_FLOOR_MASK(x, mask) ((x) & ~(mask)) ++#define PTR_ALIGN_FLOOR(p, a) \ ++ ((typeof(p)) ALIGN_FLOOR((unsigned long) (p), (a))) ++#define IS_ALIGNED(x, a) (((x) & ((typeof(x)) (a) - 1)) == 0) ++ ++/* ++ * Align pointer on natural object alignment. Object size must be power of two. ++ */ ++#define object_align(obj) PTR_ALIGN((obj), __alignof__(*(obj))) ++#define object_align_floor(obj) PTR_ALIGN_FLOOR((obj), __alignof__(*(obj))) ++ ++/** ++ * offset_align - Calculate the offset needed to align an object on its natural ++ * alignment towards higher addresses. ++ * @align_drift: object offset from an "alignment"-aligned address. ++ * @alignment: natural object alignment. Must be non-zero, power of 2. ++ * ++ * Returns the offset that must be added to align towards higher ++ * addresses. ++ */ ++static inline size_t offset_align(size_t align_drift, size_t alignment) ++{ ++ return (alignment - align_drift) & (alignment - 1); ++} ++ ++/** ++ * offset_align_floor - Calculate the offset needed to align an object ++ * on its natural alignment towards lower addresses. ++ * @align_drift: object offset from an "alignment"-aligned address. ++ * @alignment: natural object alignment. Must be non-zero, power of 2. ++ * ++ * Returns the offset that must be substracted to align towards lower addresses. ++ */ ++static inline size_t offset_align_floor(size_t align_drift, size_t alignment) ++{ ++ return (align_drift - alignment) & (alignment - 1); ++} ++ ++#endif /* __KERNEL__ */ ++ ++#endif +Index: linux.trees.git/include/linux/kernel.h +=================================================================== +--- linux.trees.git.orig/include/linux/kernel.h 2010-07-01 11:54:43.000000000 -0400 ++++ linux.trees.git/include/linux/kernel.h 2010-07-01 12:29:05.000000000 -0400 +@@ -4,8 +4,7 @@ + /* + * 'kernel.h' contains some often-used function prototypes etc + */ +-#define __ALIGN_KERNEL(x, a) __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1) +-#define __ALIGN_KERNEL_MASK(x, mask) (((x) + (mask)) & ~(mask)) ++#include <linux/align.h> + + #ifdef __KERNEL__ + +@@ -39,11 +38,6 @@ extern const char linux_proc_banner[]; + + #define STACK_MAGIC 0xdeadbeef + +-#define ALIGN(x, a) __ALIGN_KERNEL((x), (a)) +-#define __ALIGN_MASK(x, mask) __ALIGN_KERNEL_MASK((x), (mask)) +-#define PTR_ALIGN(p, a) ((typeof(p))ALIGN((unsigned long)(p), (a))) +-#define IS_ALIGNED(x, a) (((x) & ((typeof(x))(a) - 1)) == 0) +- + #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) + + /* +Index: linux.trees.git/include/linux/Kbuild +=================================================================== +--- linux.trees.git.orig/include/linux/Kbuild 2010-07-01 12:29:13.000000000 -0400 ++++ linux.trees.git/include/linux/Kbuild 2010-07-01 12:29:40.000000000 -0400 +@@ -18,6 +18,7 @@ header-y += usb/ + + header-y += affs_hardblocks.h + header-y += aio_abi.h ++header-y += align.h + header-y += arcfb.h + header-y += atmapi.h + header-y += atmarp.h diff --git a/a/content_digest b/N1/content_digest index 8652e29..be19322 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -1,12 +1,203 @@ "ref\020100709225727.312232266@efficios.com\0" - "From\0mathieu.desnoyers@efficios.com (Mathieu Desnoyers)\0" + "From\0Mathieu Desnoyers <mathieu.desnoyers@efficios.com>\0" "Subject\0[patch 01/20] Create generic alignment API (v8)\0" "Date\0Fri, 09 Jul 2010 18:57:28 -0400\0" - "To\0linux-arm-kernel@lists.infradead.org\0" + "To\0Steven Rostedt <rostedt@goodmis.org>" + " LKML <linux-kernel@vger.kernel.org>\0" + "Cc\0Linus Torvalds <torvalds@linux-foundation.org>" + Andrew Morton <akpm@linux-foundation.org> + Peter Zijlstra <peterz@infradead.org> + Ingo Molnar <mingo@elte.hu> + Frederic Weisbecker <fweisbec@gmail.com> + Thomas Gleixner <tglx@linutronix.de> + Christoph Hellwig <hch@lst.de> + Mathieu Desnoyers <mathieu.desnoyers@efficios.com> + Li Zefan <lizf@cn.fujitsu.com> + Lai Jiangshan <laijs@cn.fujitsu.com> + Johannes Berg <johannes.berg@intel.com> + Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com> + Arnaldo Carvalho de Melo <acme@infradead.org> + Tom Zanussi <tzanussi@gmail.com> + KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com> + Andi Kleen <andi@firstfloor.org> + Alexander Shishkin <virtuoso@slind.org> + Russell King - ARM Linux <linux@arm.linux.org.uk> + linux-arm-kernel@lists.infradead.org + Imre Deak <imre.deak@nokia.com> + Jamie Lokier <jamie@shareable.org> + " Alexey Dobriyan <adobriyan@gmail.com>\0" "\00:1\0" + "fn\0create-generic-alignment-api.patch\0" "b\0" - "An embedded and charset-unspecified text was scrubbed...\n" - "Name: create-generic-alignment-api.patch\n" - URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20100709/c715dd62/attachment.ksh> + "Rather than re-doing the \"alignment on a type size\" trick all over again at\n" + "different levels, import the \"ltt_align\" from LTTng into kernel.h and make this\n" + "available to everyone. Renaming to:\n" + "\n" + "- object_align()\n" + "- object_align_floor()\n" + "- offset_align()\n" + "- offset_align_floor()\n" + "\n" + "Changelog since v7:\n" + "- Add missing include/linux/Kconfig header-y.\n" + "\n" + "Changelog since v6:\n" + "- Adapt to changes introduced by\n" + " commit a79ff731a1b277d0e92d9453bdf374e04cec717a\n" + "- Use __alignof__() instead of sizeof() to support compound types.\n" + "\n" + "Changelog since v5:\n" + "- moved alignment apis to a separate header file so that it is possible\n" + " to use them from other header files which are, for example, included\n" + " from kernel.h.\n" + "\n" + "Changelog since v4:\n" + "- add missing ( ) around parameters within object_align() and\n" + " object_align_floor().\n" + "- More coding style cleanups to ALIGN() (checkpatch.pl is happy now).\n" + "\n" + "Changelog since v3:\n" + "- optimize object_align*() so fewer instructions are needed for alignment of\n" + " addresses known dynamically. Use the (already existing) \"ALIGN()\", and create\n" + " the \"ALIGN_FLOOR()\" macro.\n" + "- While we are there, let's clean up the ALIGN() macros wrt coding style. e.g.\n" + " missing parenthesis around the first use of the \"x\" parameter in ALIGN().\n" + "\n" + "Changelog since v2:\n" + "- Fix object_align*(): should use object size alignment, not pointer alignment.\n" + "\n" + "Changelog since v1:\n" + "- Align on the object natural alignment\n" + " (rather than min(arch word alignment, natural alignment))\n" + "\n" + "The advantage of separating the API in \"object alignment\" and \"offset alignment\"\n" + "is that it gives more freedom to play with offset alignment. Very useful to\n" + "implement a tracer ring-buffer alignment. (hint hint)\n" + "\n" + "Typical users will use \"object alignment\", but infrastructures like tracers\n" + "which need to perform alignment of statically known base+offsets will typically\n" + "use \"offset alignment\", because it allows to align with respect to a base rather\n" + "than to pass an absolute address.\n" + "\n" + "We use \"sizeof(object)\" rather than \"__alignof__()\" object because alignof\n" + "returns \"recommended\" object alignment for the architecture, which can be\n" + "sub-optimal on some architectures. By ensuring alignment on the object size, we\n" + "are sure to make the right choice.\n" + "\n" + "Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>\n" + "Signed-off-by: Alexander Shishkin <virtuoso@slind.org>\n" + "CC: Russell King - ARM Linux <linux@arm.linux.org.uk>\n" + "CC: linux-arm-kernel@lists.infradead.org\n" + "CC: Imre Deak <imre.deak@nokia.com>\n" + "CC: Jamie Lokier <jamie@shareable.org>\n" + "CC: rostedt@goodmis.org\n" + "CC: mingo@elte.hu\n" + "CC: Alexey Dobriyan <adobriyan@gmail.com>\n" + "---\n" + " include/linux/Kbuild | 1 \n" + " include/linux/align.h | 56 +++++++++++++++++++++++++++++++++++++++++++++++++\n" + " include/linux/kernel.h | 8 -------\n" + " 3 files changed, 58 insertions(+), 7 deletions(-)\n" + " create mode 100644 include/linux/align.h\n" + "\n" + "Index: linux.trees.git/include/linux/align.h\n" + "===================================================================\n" + "--- /dev/null\t1970-01-01 00:00:00.000000000 +0000\n" + "+++ linux.trees.git/include/linux/align.h\t2010-07-01 11:54:43.000000000 -0400\n" + "@@ -0,0 +1,56 @@\n" + "+#ifndef _LINUX_ALIGN_H\n" + "+#define _LINUX_ALIGN_H\n" + "+\n" + "+#define __ALIGN_KERNEL(x, a)\t__ALIGN_KERNEL_MASK((x), (typeof(x))(a) - 1)\n" + "+#define __ALIGN_KERNEL_MASK(x, mask) \\\n" + "+\t\t\t\t(((x) + (mask)) & ~(mask))\n" + "+\n" + "+#ifdef __KERNEL__\n" + "+\n" + "+#include <linux/types.h>\n" + "+\n" + "+#define ALIGN(x, a)\t\t__ALIGN_KERNEL((x), (a))\n" + "+#define __ALIGN_MASK(x, mask)\t__ALIGN_KERNEL_MASK((x), (mask))\n" + "+#define PTR_ALIGN(p, a)\t\t((typeof(p)) ALIGN((unsigned long) (p), (a)))\n" + "+#define ALIGN_FLOOR(x, a)\t__ALIGN_FLOOR_MASK((x), (typeof(x)) (a) - 1)\n" + "+#define __ALIGN_FLOOR_MASK(x, mask)\t((x) & ~(mask))\n" + "+#define PTR_ALIGN_FLOOR(p, a) \\\n" + "+\t\t\t((typeof(p)) ALIGN_FLOOR((unsigned long) (p), (a)))\n" + "+#define IS_ALIGNED(x, a)\t(((x) & ((typeof(x)) (a) - 1)) == 0)\n" + "+\n" + "+/*\n" + "+ * Align pointer on natural object alignment. Object size must be power of two.\n" + "+ */\n" + "+#define object_align(obj)\tPTR_ALIGN((obj), __alignof__(*(obj)))\n" + "+#define object_align_floor(obj)\tPTR_ALIGN_FLOOR((obj), __alignof__(*(obj)))\n" + "+\n" + "+/**\n" + "+ * offset_align - Calculate the offset needed to align an object on its natural\n" + "+ * alignment towards higher addresses.\n" + "+ * @align_drift: object offset from an \"alignment\"-aligned address.\n" + "+ * @alignment: natural object alignment. Must be non-zero, power of 2.\n" + "+ *\n" + "+ * Returns the offset that must be added to align towards higher\n" + "+ * addresses.\n" + "+ */\n" + "+static inline size_t offset_align(size_t align_drift, size_t alignment)\n" + "+{\n" + "+\treturn (alignment - align_drift) & (alignment - 1);\n" + "+}\n" + "+\n" + "+/**\n" + "+ * offset_align_floor - Calculate the offset needed to align an object\n" + "+ * on its natural alignment towards lower addresses.\n" + "+ * @align_drift: object offset from an \"alignment\"-aligned address.\n" + "+ * @alignment: natural object alignment. Must be non-zero, power of 2.\n" + "+ *\n" + "+ * Returns the offset that must be substracted to align towards lower addresses.\n" + "+ */\n" + "+static inline size_t offset_align_floor(size_t align_drift, size_t alignment)\n" + "+{\n" + "+\treturn (align_drift - alignment) & (alignment - 1);\n" + "+}\n" + "+\n" + "+#endif /* __KERNEL__ */\n" + "+\n" + "+#endif\n" + "Index: linux.trees.git/include/linux/kernel.h\n" + "===================================================================\n" + "--- linux.trees.git.orig/include/linux/kernel.h\t2010-07-01 11:54:43.000000000 -0400\n" + "+++ linux.trees.git/include/linux/kernel.h\t2010-07-01 12:29:05.000000000 -0400\n" + "@@ -4,8 +4,7 @@\n" + " /*\n" + " * 'kernel.h' contains some often-used function prototypes etc\n" + " */\n" + "-#define __ALIGN_KERNEL(x, a)\t\t__ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)\n" + "-#define __ALIGN_KERNEL_MASK(x, mask)\t(((x) + (mask)) & ~(mask))\n" + "+#include <linux/align.h>\n" + " \n" + " #ifdef __KERNEL__\n" + " \n" + "@@ -39,11 +38,6 @@ extern const char linux_proc_banner[];\n" + " \n" + " #define STACK_MAGIC\t0xdeadbeef\n" + " \n" + "-#define ALIGN(x, a)\t\t__ALIGN_KERNEL((x), (a))\n" + "-#define __ALIGN_MASK(x, mask)\t__ALIGN_KERNEL_MASK((x), (mask))\n" + "-#define PTR_ALIGN(p, a)\t\t((typeof(p))ALIGN((unsigned long)(p), (a)))\n" + "-#define IS_ALIGNED(x, a)\t\t(((x) & ((typeof(x))(a) - 1)) == 0)\n" + "-\n" + " #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr))\n" + " \n" + " /*\n" + "Index: linux.trees.git/include/linux/Kbuild\n" + "===================================================================\n" + "--- linux.trees.git.orig/include/linux/Kbuild\t2010-07-01 12:29:13.000000000 -0400\n" + "+++ linux.trees.git/include/linux/Kbuild\t2010-07-01 12:29:40.000000000 -0400\n" + "@@ -18,6 +18,7 @@ header-y += usb/\n" + " \n" + " header-y += affs_hardblocks.h\n" + " header-y += aio_abi.h\n" + "+header-y += align.h\n" + " header-y += arcfb.h\n" + " header-y += atmapi.h\n" + header-y += atmarp.h -2ed95ac7011ee9795e322363d20086e7c1657c533106ac113131d4cbb998bc6c +48d0cc55079cb78c4e9d70d231d0c98437e1d07f1667432e7a6cb54a98c8a48f
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.