diff options
author | David S. Miller <davem@davemloft.net> | 2017-10-22 08:36:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-10-22 08:39:14 -0400 |
commit | f8ddadc4db6c7b7029b6d0e0d9af24f74ad27ca2 (patch) | |
tree | 0a6432aba336bae42313613f4c891bcfce02bd4e /include/linux/kernel.h | |
parent | bdd091bab8c631bd2801af838e344fad34566410 (diff) | |
parent | b5ac3beb5a9f0ef0ea64cd85faf94c0dc4de0e42 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
There were quite a few overlapping sets of changes here.
Daniel's bug fix for off-by-ones in the new BPF branch instructions,
along with the added allowances for "data_end > ptr + x" forms
collided with the metadata additions.
Along with those three changes came veritifer test cases, which in
their final form I tried to group together properly. If I had just
trimmed GIT's conflict tags as-is, this would have split up the
meta tests unnecessarily.
In the socketmap code, a set of preemption disabling changes
overlapped with the rename of bpf_compute_data_end() to
bpf_compute_data_pointers().
Changes were made to the mv88e6060.c driver set addr method
which got removed in net-next.
The hyperv transport socket layer had a locking change in 'net'
which overlapped with a change of socket state macro usage
in 'net-next'.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 90 |
1 files changed, 74 insertions, 16 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 0ad4c3044cf9..91189bb0c818 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -44,6 +44,12 @@ | |||
44 | 44 | ||
45 | #define STACK_MAGIC 0xdeadbeef | 45 | #define STACK_MAGIC 0xdeadbeef |
46 | 46 | ||
47 | /** | ||
48 | * REPEAT_BYTE - repeat the value @x multiple times as an unsigned long value | ||
49 | * @x: value to repeat | ||
50 | * | ||
51 | * NOTE: @x is not checked for > 0xff; larger values produce odd results. | ||
52 | */ | ||
47 | #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) | 53 | #define REPEAT_BYTE(x) ((~0ul / 0xff) * (x)) |
48 | 54 | ||
49 | /* @a is a power of 2 value */ | 55 | /* @a is a power of 2 value */ |
@@ -57,6 +63,10 @@ | |||
57 | #define READ 0 | 63 | #define READ 0 |
58 | #define WRITE 1 | 64 | #define WRITE 1 |
59 | 65 | ||
66 | /** | ||
67 | * ARRAY_SIZE - get the number of elements in array @arr | ||
68 | * @arr: array to be sized | ||
69 | */ | ||
60 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) | 70 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) |
61 | 71 | ||
62 | #define u64_to_user_ptr(x) ( \ | 72 | #define u64_to_user_ptr(x) ( \ |
@@ -76,7 +86,15 @@ | |||
76 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) | 86 | #define round_up(x, y) ((((x)-1) | __round_mask(x, y))+1) |
77 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) | 87 | #define round_down(x, y) ((x) & ~__round_mask(x, y)) |
78 | 88 | ||
89 | /** | ||
90 | * FIELD_SIZEOF - get the size of a struct's field | ||
91 | * @t: the target struct | ||
92 | * @f: the target struct's field | ||
93 | * Return: the size of @f in the struct definition without having a | ||
94 | * declared instance of @t. | ||
95 | */ | ||
79 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) | 96 | #define FIELD_SIZEOF(t, f) (sizeof(((t*)0)->f)) |
97 | |||
80 | #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP | 98 | #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP |
81 | 99 | ||
82 | #define DIV_ROUND_DOWN_ULL(ll, d) \ | 100 | #define DIV_ROUND_DOWN_ULL(ll, d) \ |
@@ -107,7 +125,7 @@ | |||
107 | /* | 125 | /* |
108 | * Divide positive or negative dividend by positive or negative divisor | 126 | * Divide positive or negative dividend by positive or negative divisor |
109 | * and round to closest integer. Result is undefined for negative | 127 | * and round to closest integer. Result is undefined for negative |
110 | * divisors if he dividend variable type is unsigned and for negative | 128 | * divisors if the dividend variable type is unsigned and for negative |
111 | * dividends if the divisor variable type is unsigned. | 129 | * dividends if the divisor variable type is unsigned. |
112 | */ | 130 | */ |
113 | #define DIV_ROUND_CLOSEST(x, divisor)( \ | 131 | #define DIV_ROUND_CLOSEST(x, divisor)( \ |
@@ -247,13 +265,13 @@ extern int _cond_resched(void); | |||
247 | * @ep_ro: right open interval endpoint | 265 | * @ep_ro: right open interval endpoint |
248 | * | 266 | * |
249 | * Perform a "reciprocal multiplication" in order to "scale" a value into | 267 | * Perform a "reciprocal multiplication" in order to "scale" a value into |
250 | * range [0, ep_ro), where the upper interval endpoint is right-open. | 268 | * range [0, @ep_ro), where the upper interval endpoint is right-open. |
251 | * This is useful, e.g. for accessing a index of an array containing | 269 | * This is useful, e.g. for accessing a index of an array containing |
252 | * ep_ro elements, for example. Think of it as sort of modulus, only that | 270 | * @ep_ro elements, for example. Think of it as sort of modulus, only that |
253 | * the result isn't that of modulo. ;) Note that if initial input is a | 271 | * the result isn't that of modulo. ;) Note that if initial input is a |
254 | * small value, then result will return 0. | 272 | * small value, then result will return 0. |
255 | * | 273 | * |
256 | * Return: a result based on val in interval [0, ep_ro). | 274 | * Return: a result based on @val in interval [0, @ep_ro). |
257 | */ | 275 | */ |
258 | static inline u32 reciprocal_scale(u32 val, u32 ep_ro) | 276 | static inline u32 reciprocal_scale(u32 val, u32 ep_ro) |
259 | { | 277 | { |
@@ -618,8 +636,8 @@ do { \ | |||
618 | * trace_printk - printf formatting in the ftrace buffer | 636 | * trace_printk - printf formatting in the ftrace buffer |
619 | * @fmt: the printf format for printing | 637 | * @fmt: the printf format for printing |
620 | * | 638 | * |
621 | * Note: __trace_printk is an internal function for trace_printk and | 639 | * Note: __trace_printk is an internal function for trace_printk() and |
622 | * the @ip is passed in via the trace_printk macro. | 640 | * the @ip is passed in via the trace_printk() macro. |
623 | * | 641 | * |
624 | * This function allows a kernel developer to debug fast path sections | 642 | * This function allows a kernel developer to debug fast path sections |
625 | * that printk is not appropriate for. By scattering in various | 643 | * that printk is not appropriate for. By scattering in various |
@@ -629,7 +647,7 @@ do { \ | |||
629 | * This is intended as a debugging tool for the developer only. | 647 | * This is intended as a debugging tool for the developer only. |
630 | * Please refrain from leaving trace_printks scattered around in | 648 | * Please refrain from leaving trace_printks scattered around in |
631 | * your code. (Extra memory is used for special buffers that are | 649 | * your code. (Extra memory is used for special buffers that are |
632 | * allocated when trace_printk() is used) | 650 | * allocated when trace_printk() is used.) |
633 | * | 651 | * |
634 | * A little optization trick is done here. If there's only one | 652 | * A little optization trick is done here. If there's only one |
635 | * argument, there's no need to scan the string for printf formats. | 653 | * argument, there's no need to scan the string for printf formats. |
@@ -681,7 +699,7 @@ int __trace_printk(unsigned long ip, const char *fmt, ...); | |||
681 | * the @ip is passed in via the trace_puts macro. | 699 | * the @ip is passed in via the trace_puts macro. |
682 | * | 700 | * |
683 | * This is similar to trace_printk() but is made for those really fast | 701 | * This is similar to trace_printk() but is made for those really fast |
684 | * paths that a developer wants the least amount of "Heisenbug" affects, | 702 | * paths that a developer wants the least amount of "Heisenbug" effects, |
685 | * where the processing of the print format is still too much. | 703 | * where the processing of the print format is still too much. |
686 | * | 704 | * |
687 | * This function allows a kernel developer to debug fast path sections | 705 | * This function allows a kernel developer to debug fast path sections |
@@ -692,7 +710,7 @@ int __trace_printk(unsigned long ip, const char *fmt, ...); | |||
692 | * This is intended as a debugging tool for the developer only. | 710 | * This is intended as a debugging tool for the developer only. |
693 | * Please refrain from leaving trace_puts scattered around in | 711 | * Please refrain from leaving trace_puts scattered around in |
694 | * your code. (Extra memory is used for special buffers that are | 712 | * your code. (Extra memory is used for special buffers that are |
695 | * allocated when trace_puts() is used) | 713 | * allocated when trace_puts() is used.) |
696 | * | 714 | * |
697 | * Returns: 0 if nothing was written, positive # if string was. | 715 | * Returns: 0 if nothing was written, positive # if string was. |
698 | * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) | 716 | * (1 when __trace_bputs is used, strlen(str) when __trace_puts is used) |
@@ -771,6 +789,12 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
771 | t2 min2 = (y); \ | 789 | t2 min2 = (y); \ |
772 | (void) (&min1 == &min2); \ | 790 | (void) (&min1 == &min2); \ |
773 | min1 < min2 ? min1 : min2; }) | 791 | min1 < min2 ? min1 : min2; }) |
792 | |||
793 | /** | ||
794 | * min - return minimum of two values of the same or compatible types | ||
795 | * @x: first value | ||
796 | * @y: second value | ||
797 | */ | ||
774 | #define min(x, y) \ | 798 | #define min(x, y) \ |
775 | __min(typeof(x), typeof(y), \ | 799 | __min(typeof(x), typeof(y), \ |
776 | __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ | 800 | __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ |
@@ -781,12 +805,31 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
781 | t2 max2 = (y); \ | 805 | t2 max2 = (y); \ |
782 | (void) (&max1 == &max2); \ | 806 | (void) (&max1 == &max2); \ |
783 | max1 > max2 ? max1 : max2; }) | 807 | max1 > max2 ? max1 : max2; }) |
808 | |||
809 | /** | ||
810 | * max - return maximum of two values of the same or compatible types | ||
811 | * @x: first value | ||
812 | * @y: second value | ||
813 | */ | ||
784 | #define max(x, y) \ | 814 | #define max(x, y) \ |
785 | __max(typeof(x), typeof(y), \ | 815 | __max(typeof(x), typeof(y), \ |
786 | __UNIQUE_ID(max1_), __UNIQUE_ID(max2_), \ | 816 | __UNIQUE_ID(max1_), __UNIQUE_ID(max2_), \ |
787 | x, y) | 817 | x, y) |
788 | 818 | ||
819 | /** | ||
820 | * min3 - return minimum of three values | ||
821 | * @x: first value | ||
822 | * @y: second value | ||
823 | * @z: third value | ||
824 | */ | ||
789 | #define min3(x, y, z) min((typeof(x))min(x, y), z) | 825 | #define min3(x, y, z) min((typeof(x))min(x, y), z) |
826 | |||
827 | /** | ||
828 | * max3 - return maximum of three values | ||
829 | * @x: first value | ||
830 | * @y: second value | ||
831 | * @z: third value | ||
832 | */ | ||
790 | #define max3(x, y, z) max((typeof(x))max(x, y), z) | 833 | #define max3(x, y, z) max((typeof(x))max(x, y), z) |
791 | 834 | ||
792 | /** | 835 | /** |
@@ -805,8 +848,8 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
805 | * @lo: lowest allowable value | 848 | * @lo: lowest allowable value |
806 | * @hi: highest allowable value | 849 | * @hi: highest allowable value |
807 | * | 850 | * |
808 | * This macro does strict typechecking of lo/hi to make sure they are of the | 851 | * This macro does strict typechecking of @lo/@hi to make sure they are of the |
809 | * same type as val. See the unnecessary pointer comparisons. | 852 | * same type as @val. See the unnecessary pointer comparisons. |
810 | */ | 853 | */ |
811 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) | 854 | #define clamp(val, lo, hi) min((typeof(val))max(val, lo), hi) |
812 | 855 | ||
@@ -816,11 +859,24 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
816 | * | 859 | * |
817 | * Or not use min/max/clamp at all, of course. | 860 | * Or not use min/max/clamp at all, of course. |
818 | */ | 861 | */ |
862 | |||
863 | /** | ||
864 | * min_t - return minimum of two values, using the specified type | ||
865 | * @type: data type to use | ||
866 | * @x: first value | ||
867 | * @y: second value | ||
868 | */ | ||
819 | #define min_t(type, x, y) \ | 869 | #define min_t(type, x, y) \ |
820 | __min(type, type, \ | 870 | __min(type, type, \ |
821 | __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ | 871 | __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ |
822 | x, y) | 872 | x, y) |
823 | 873 | ||
874 | /** | ||
875 | * max_t - return maximum of two values, using the specified type | ||
876 | * @type: data type to use | ||
877 | * @x: first value | ||
878 | * @y: second value | ||
879 | */ | ||
824 | #define max_t(type, x, y) \ | 880 | #define max_t(type, x, y) \ |
825 | __max(type, type, \ | 881 | __max(type, type, \ |
826 | __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ | 882 | __UNIQUE_ID(min1_), __UNIQUE_ID(min2_), \ |
@@ -834,7 +890,7 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
834 | * @hi: maximum allowable value | 890 | * @hi: maximum allowable value |
835 | * | 891 | * |
836 | * This macro does no typechecking and uses temporary variables of type | 892 | * This macro does no typechecking and uses temporary variables of type |
837 | * 'type' to make all the comparisons. | 893 | * @type to make all the comparisons. |
838 | */ | 894 | */ |
839 | #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi) | 895 | #define clamp_t(type, val, lo, hi) min_t(type, max_t(type, val, lo), hi) |
840 | 896 | ||
@@ -845,15 +901,17 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } | |||
845 | * @hi: maximum allowable value | 901 | * @hi: maximum allowable value |
846 | * | 902 | * |
847 | * This macro does no typechecking and uses temporary variables of whatever | 903 | * This macro does no typechecking and uses temporary variables of whatever |
848 | * type the input argument 'val' is. This is useful when val is an unsigned | 904 | * type the input argument @val is. This is useful when @val is an unsigned |
849 | * type and min and max are literals that will otherwise be assigned a signed | 905 | * type and @lo and @hi are literals that will otherwise be assigned a signed |
850 | * integer type. | 906 | * integer type. |
851 | */ | 907 | */ |
852 | #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) | 908 | #define clamp_val(val, lo, hi) clamp_t(typeof(val), val, lo, hi) |
853 | 909 | ||
854 | 910 | ||
855 | /* | 911 | /** |
856 | * swap - swap value of @a and @b | 912 | * swap - swap values of @a and @b |
913 | * @a: first value | ||
914 | * @b: second value | ||
857 | */ | 915 | */ |
858 | #define swap(a, b) \ | 916 | #define swap(a, b) \ |
859 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) | 917 | do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while (0) |