Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Sat, Jun 29, 2019 at 09:45:10AM -0700, Joe Perches wrote: > On Sat, 2019-06-29 at 17:25 +0300, Alexey Dobriyan wrote: > > On Tue, Jun 11, 2019 at 03:00:10PM -0600, Andreas Dilger wrote: > > > On Jun 11, 2019, at 2:48 PM, Andrew Morton > > > wrote: > > > > On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini > > > > wrote: > > > I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() > > > is about 30x, and SIZEOF_FIELD() is only about 5x. > > > > > > That said, I'm much more in favour of "sizeof_field()" or > > > "sizeof_member()" > > > than FIELD_SIZEOF(). Not only does that better match "offsetof()", with > > > which it is closely related, but is also closer to the original > > > "sizeof()". > > > > > > Since this is a rather trivial change, it can be split into a number of > > > patches to get approval/landing via subsystem maintainers, and there is no > > > huge urgency to remove the original macros until the users are gone. It > > > would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so > > > they don't gain more users, and the remaining FIELD_SIZEOF() users can be > > > whittled away as the patches come through the maintainer trees. > > > > The signature should be > > > > sizeof_member(T, m) > > > > it is proper English, > > it is lowercase, so is easier to type, > > it uses standard term (member, not field), > > it blends in with standard "sizeof" operator, > > yes please. > > Also, a simple script conversion applied > immediately after an rc1 might be easiest > rather than individual patches. This seems reasonable to me. I think the patch steps would be: 1) implement sizeof_member(T, m) as a stand-alone macro 2) do a scripted replacement of all identical macros. 3) remove all the identical macros. Step 2 can be a patch that includes the script used to do the replacement. That way Linus can choose to just run the script instead of taking the patch. -- Kees Cook ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Tue, Jun 11, 2019 at 03:00:10PM -0600, Andreas Dilger wrote: > On Jun 11, 2019, at 2:48 PM, Andrew Morton wrote: > > > > On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini > > wrote: > I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() > is about 30x, and SIZEOF_FIELD() is only about 5x. > > That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" > than FIELD_SIZEOF(). Not only does that better match "offsetof()", with > which it is closely related, but is also closer to the original "sizeof()". > > Since this is a rather trivial change, it can be split into a number of > patches to get approval/landing via subsystem maintainers, and there is no > huge urgency to remove the original macros until the users are gone. It > would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so > they don't gain more users, and the remaining FIELD_SIZEOF() users can be > whittled away as the patches come through the maintainer trees. The signature should be sizeof_member(T, m) it is proper English, it is lowercase, so is easier to type, it uses standard term (member, not field), it blends in with standard "sizeof" operator, ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Sat, 2019-06-29 at 17:25 +0300, Alexey Dobriyan wrote: > On Tue, Jun 11, 2019 at 03:00:10PM -0600, Andreas Dilger wrote: > > On Jun 11, 2019, at 2:48 PM, Andrew Morton > > wrote: > > > On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini > > > wrote: > > I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() > > is about 30x, and SIZEOF_FIELD() is only about 5x. > > > > That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" > > than FIELD_SIZEOF(). Not only does that better match "offsetof()", with > > which it is closely related, but is also closer to the original "sizeof()". > > > > Since this is a rather trivial change, it can be split into a number of > > patches to get approval/landing via subsystem maintainers, and there is no > > huge urgency to remove the original macros until the users are gone. It > > would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so > > they don't gain more users, and the remaining FIELD_SIZEOF() users can be > > whittled away as the patches come through the maintainer trees. > > The signature should be > > sizeof_member(T, m) > > it is proper English, > it is lowercase, so is easier to type, > it uses standard term (member, not field), > it blends in with standard "sizeof" operator, yes please. Also, a simple script conversion applied immediately after an rc1 might be easiest rather than individual patches. ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Tue, Jun 11, 2019 at 5:00 PM Shyam Saini wrote: > > Currently, there are 3 different macros, namely sizeof_field, SIZEOF_FIELD > and FIELD_SIZEOF which are used to calculate the size of a member of > structure, so to bring uniformity in entire kernel source tree lets use > FIELD_SIZEOF and replace all occurrences of other two macros with this. > > For this purpose, redefine FIELD_SIZEOF in include/linux/stddef.h and > tools/testing/selftests/bpf/bpf_util.h and remove its defination from > include/linux/kernel.h please dont. bpf_util.h is a user space header. Please leave it as-is. ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Jun 11, 2019, at 2:48 PM, Andrew Morton wrote: > > On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini > wrote: > >> Currently, there are 3 different macros, namely sizeof_field, SIZEOF_FIELD >> and FIELD_SIZEOF which are used to calculate the size of a member of >> structure, so to bring uniformity in entire kernel source tree lets use >> FIELD_SIZEOF and replace all occurrences of other two macros with this. >> >> For this purpose, redefine FIELD_SIZEOF in include/linux/stddef.h and >> tools/testing/selftests/bpf/bpf_util.h and remove its defination from >> include/linux/kernel.h >> >> In favour of FIELD_SIZEOF, this patch also deprecates other two similar >> macros sizeof_field and SIZEOF_FIELD. >> >> For code compatibility reason, retain sizeof_field macro as a wrapper macro >> to FIELD_SIZEOF > > As Alexey has pointed out, C structs and unions don't have fields - > they have members. So this is an opportunity to switch everything to > a new member_sizeof(). > > What do people think of that and how does this impact the patch footprint? I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() is about 30x, and SIZEOF_FIELD() is only about 5x. That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" than FIELD_SIZEOF(). Not only does that better match "offsetof()", with which it is closely related, but is also closer to the original "sizeof()". Since this is a rather trivial change, it can be split into a number of patches to get approval/landing via subsystem maintainers, and there is no huge urgency to remove the original macros until the users are gone. It would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so they don't gain more users, and the remaining FIELD_SIZEOF() users can be whittled away as the patches come through the maintainer trees. Cheers, Andreas signature.asc Description: Message signed with OpenPGP ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Jun 11, 2019, at 3:09 PM, Andrew Morton wrote: > > On Tue, 11 Jun 2019 15:00:10 -0600 Andreas Dilger wrote: > to FIELD_SIZEOF >>> >>> As Alexey has pointed out, C structs and unions don't have fields - >>> they have members. So this is an opportunity to switch everything to >>> a new member_sizeof(). >>> >>> What do people think of that and how does this impact the patch footprint? >> >> I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() >> is about 30x, and SIZEOF_FIELD() is only about 5x. > > Erk. Sorry, I should have grepped. > >> That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" >> than FIELD_SIZEOF(). Not only does that better match "offsetof()", with >> which it is closely related, but is also closer to the original "sizeof()". >> >> Since this is a rather trivial change, it can be split into a number of >> patches to get approval/landing via subsystem maintainers, and there is no >> huge urgency to remove the original macros until the users are gone. It >> would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so >> they don't gain more users, and the remaining FIELD_SIZEOF() users can be >> whittled away as the patches come through the maintainer trees. > > In that case I'd say let's live with FIELD_SIZEOF() and remove > sizeof_field() and SIZEOF_FIELD(). The real question is whether we want to live with a sub-standard macro for the next 20 years rather than taking the opportunity to clean it up now? > I'm a bit surprised that the FIELD_SIZEOF() definition ends up in > stddef.h rather than in kernel.h where such things are normally > defined. Why is that? Cheers, Andreas signature.asc Description: Message signed with OpenPGP ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
Hi Kees, Cc'ing William Kucharski, > On Wed, Jun 12, 2019 at 01:08:36AM +0530, Shyam Saini wrote: > > In favour of FIELD_SIZEOF, this patch also deprecates other two similar > > macros sizeof_field and SIZEOF_FIELD. > > > > For code compatibility reason, retain sizeof_field macro as a wrapper macro > > to FIELD_SIZEOF > > Can you explain this part? First sentence says you want to remove > sizeof_field, and the second says you're keeping it? I thought the point > was to switch all of these to FIELD_SIZEOF()? Previously, William [1] suggested to retain sizeof_field as macro to FIELD_SIZEOF for code compatibility reason. I have removed all the usage of sizeof_field apart from retained wrapper macro definition. [1] https://patchwork.ozlabs.org/patch/1085275/ Thanks, Shyam > > > > arch/arm64/include/asm/processor.h | 10 +- > > arch/mips/cavium-octeon/executive/cvmx-bootmem.c | 9 + > > drivers/gpu/drm/i915/gvt/scheduler.c | 2 +- > > drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c | 4 ++-- > > fs/befs/linuxvfs.c | 2 +- > > fs/ext2/super.c| 2 +- > > fs/ext4/super.c| 2 +- > > fs/freevxfs/vxfs_super.c | 2 +- > > fs/orangefs/super.c| 2 +- > > fs/ufs/super.c | 2 +- > > include/linux/kernel.h | 9 - > > include/linux/slab.h | 2 +- > > include/linux/stddef.h | 17 ++--- > > kernel/fork.c | 2 +- > > kernel/utsname.c | 2 +- > > net/caif/caif_socket.c | 2 +- > > net/core/skbuff.c | 2 +- > > net/ipv4/raw.c | 2 +- > > net/ipv6/raw.c | 2 +- > > net/sctp/socket.c | 4 ++-- > > tools/testing/selftests/bpf/bpf_util.h | 22 > > +++--- > > virt/kvm/kvm_main.c| 2 +- > > 22 files changed, 58 insertions(+), 47 deletions(-) > > > > diff --git a/arch/arm64/include/asm/processor.h > > b/arch/arm64/include/asm/processor.h > > index fcd0e691b1ea..ace906d887cc 100644 > > --- a/arch/arm64/include/asm/processor.h > > +++ b/arch/arm64/include/asm/processor.h > > @@ -164,13 +164,13 @@ static inline void > > arch_thread_struct_whitelist(unsigned long *offset, > > unsigned long *size) > > { > > /* Verify that there is no padding among the whitelisted fields: */ > > - BUILD_BUG_ON(sizeof_field(struct thread_struct, uw) != > > - sizeof_field(struct thread_struct, uw.tp_value) + > > - sizeof_field(struct thread_struct, uw.tp2_value) + > > - sizeof_field(struct thread_struct, uw.fpsimd_state)); > > + BUILD_BUG_ON(FIELD_SIZEOF(struct thread_struct, uw) != > > + FIELD_SIZEOF(struct thread_struct, uw.tp_value) + > > + FIELD_SIZEOF(struct thread_struct, uw.tp2_value) + > > + FIELD_SIZEOF(struct thread_struct, uw.fpsimd_state)); > > > > *offset = offsetof(struct thread_struct, uw); > > - *size = sizeof_field(struct thread_struct, uw); > > + *size = FIELD_SIZEOF(struct thread_struct, uw); > > } > > > > #ifdef CONFIG_COMPAT > > diff --git a/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > > b/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > > index ba8f82a29a81..44b506a14666 100644 > > --- a/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > > +++ b/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > > @@ -45,13 +45,6 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc; > > /* See header file for descriptions of functions */ > > > > /** > > - * This macro returns the size of a member of a structure. > > - * Logically it is the same as "sizeof(s::field)" in C++, but > > - * C lacks the "::" operator. > > - */ > > -#define SIZEOF_FIELD(s, field) sizeof(((s *)NULL)->field) > > - > > -/** > > * This macro returns a member of the > > * cvmx_bootmem_named_block_desc_t structure. These members can't > > * be directly addressed as they might be in memory not directly > > @@ -65,7 +58,7 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc; > > #define CVMX_BOOTMEM_NAMED_GET_FIELD(addr, field)\ > > __cvmx_bootmem_desc_get(addr, \ > > offsetof(struct cvmx_bootmem_named_block_desc, field), \ > > - SIZEOF_FIELD(struct cvmx_bootmem_named_block_desc, field)) > > + FIELD_SIZEOF(struct cvmx_bootmem_named_block_desc, field)) > > > > /** > > * This function is the implementation of the get macros
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
Hi Andrew, > > On Tue, 11 Jun 2019 15:00:10 -0600 Andreas Dilger wrote: > > > >> to FIELD_SIZEOF > > > > > > As Alexey has pointed out, C structs and unions don't have fields - > > > they have members. So this is an opportunity to switch everything to > > > a new member_sizeof(). > > > > > > What do people think of that and how does this impact the patch footprint? > > > > I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() > > is about 30x, and SIZEOF_FIELD() is only about 5x. > > Erk. Sorry, I should have grepped. > > > That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" > > than FIELD_SIZEOF(). Not only does that better match "offsetof()", with > > which it is closely related, but is also closer to the original "sizeof()". > > > > Since this is a rather trivial change, it can be split into a number of > > patches to get approval/landing via subsystem maintainers, and there is no > > huge urgency to remove the original macros until the users are gone. It > > would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so > > they don't gain more users, and the remaining FIELD_SIZEOF() users can be > > whittled away as the patches come through the maintainer trees. > > In that case I'd say let's live with FIELD_SIZEOF() and remove > sizeof_field() and SIZEOF_FIELD(). > > I'm a bit surprised that the FIELD_SIZEOF() definition ends up in > stddef.h rather than in kernel.h where such things are normally > defined. Why is that? Thanks for pointing out this, I was not aware if this is a convention. Anyway, I'll keep FIELD_SIZEOF definition in kernel.h in next version. ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
[Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
Currently, there are 3 different macros, namely sizeof_field, SIZEOF_FIELD and FIELD_SIZEOF which are used to calculate the size of a member of structure, so to bring uniformity in entire kernel source tree lets use FIELD_SIZEOF and replace all occurrences of other two macros with this. For this purpose, redefine FIELD_SIZEOF in include/linux/stddef.h and tools/testing/selftests/bpf/bpf_util.h and remove its defination from include/linux/kernel.h In favour of FIELD_SIZEOF, this patch also deprecates other two similar macros sizeof_field and SIZEOF_FIELD. For code compatibility reason, retain sizeof_field macro as a wrapper macro to FIELD_SIZEOF Signed-off-by: Shyam Saini --- Changelog: V1->V2 - Consolidate previous patch 1 and 2 into single patch - For code compatibility reason, retain sizeof_field macro as a wrapper macro to FIELD_SIZEOF arch/arm64/include/asm/processor.h | 10 +- arch/mips/cavium-octeon/executive/cvmx-bootmem.c | 9 + drivers/gpu/drm/i915/gvt/scheduler.c | 2 +- drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c | 4 ++-- fs/befs/linuxvfs.c | 2 +- fs/ext2/super.c| 2 +- fs/ext4/super.c| 2 +- fs/freevxfs/vxfs_super.c | 2 +- fs/orangefs/super.c| 2 +- fs/ufs/super.c | 2 +- include/linux/kernel.h | 9 - include/linux/slab.h | 2 +- include/linux/stddef.h | 17 ++--- kernel/fork.c | 2 +- kernel/utsname.c | 2 +- net/caif/caif_socket.c | 2 +- net/core/skbuff.c | 2 +- net/ipv4/raw.c | 2 +- net/ipv6/raw.c | 2 +- net/sctp/socket.c | 4 ++-- tools/testing/selftests/bpf/bpf_util.h | 22 +++--- virt/kvm/kvm_main.c| 2 +- 22 files changed, 58 insertions(+), 47 deletions(-) diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index fcd0e691b1ea..ace906d887cc 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -164,13 +164,13 @@ static inline void arch_thread_struct_whitelist(unsigned long *offset, unsigned long *size) { /* Verify that there is no padding among the whitelisted fields: */ - BUILD_BUG_ON(sizeof_field(struct thread_struct, uw) != -sizeof_field(struct thread_struct, uw.tp_value) + -sizeof_field(struct thread_struct, uw.tp2_value) + -sizeof_field(struct thread_struct, uw.fpsimd_state)); + BUILD_BUG_ON(FIELD_SIZEOF(struct thread_struct, uw) != +FIELD_SIZEOF(struct thread_struct, uw.tp_value) + +FIELD_SIZEOF(struct thread_struct, uw.tp2_value) + +FIELD_SIZEOF(struct thread_struct, uw.fpsimd_state)); *offset = offsetof(struct thread_struct, uw); - *size = sizeof_field(struct thread_struct, uw); + *size = FIELD_SIZEOF(struct thread_struct, uw); } #ifdef CONFIG_COMPAT diff --git a/arch/mips/cavium-octeon/executive/cvmx-bootmem.c b/arch/mips/cavium-octeon/executive/cvmx-bootmem.c index ba8f82a29a81..44b506a14666 100644 --- a/arch/mips/cavium-octeon/executive/cvmx-bootmem.c +++ b/arch/mips/cavium-octeon/executive/cvmx-bootmem.c @@ -45,13 +45,6 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc; /* See header file for descriptions of functions */ /** - * This macro returns the size of a member of a structure. - * Logically it is the same as "sizeof(s::field)" in C++, but - * C lacks the "::" operator. - */ -#define SIZEOF_FIELD(s, field) sizeof(((s *)NULL)->field) - -/** * This macro returns a member of the * cvmx_bootmem_named_block_desc_t structure. These members can't * be directly addressed as they might be in memory not directly @@ -65,7 +58,7 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc; #define CVMX_BOOTMEM_NAMED_GET_FIELD(addr, field) \ __cvmx_bootmem_desc_get(addr, \ offsetof(struct cvmx_bootmem_named_block_desc, field), \ - SIZEOF_FIELD(struct cvmx_bootmem_named_block_desc, field)) + FIELD_SIZEOF(struct cvmx_bootmem_named_block_desc, field)) /** * This function is the implementation of the get macros defined diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c b/drivers/gpu/drm/i915/gvt/scheduler.c index 0f919f0a43d4..820f95a52542 100644 --- a/drivers/gpu/drm/i915/gvt/scheduler.c +++
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Tue, 11 Jun 2019 15:00:10 -0600 Andreas Dilger wrote: > >> to FIELD_SIZEOF > > > > As Alexey has pointed out, C structs and unions don't have fields - > > they have members. So this is an opportunity to switch everything to > > a new member_sizeof(). > > > > What do people think of that and how does this impact the patch footprint? > > I did a check, and FIELD_SIZEOF() is used about 350x, while sizeof_field() > is about 30x, and SIZEOF_FIELD() is only about 5x. Erk. Sorry, I should have grepped. > That said, I'm much more in favour of "sizeof_field()" or "sizeof_member()" > than FIELD_SIZEOF(). Not only does that better match "offsetof()", with > which it is closely related, but is also closer to the original "sizeof()". > > Since this is a rather trivial change, it can be split into a number of > patches to get approval/landing via subsystem maintainers, and there is no > huge urgency to remove the original macros until the users are gone. It > would make sense to remove SIZEOF_FIELD() and sizeof_field() quickly so > they don't gain more users, and the remaining FIELD_SIZEOF() users can be > whittled away as the patches come through the maintainer trees. In that case I'd say let's live with FIELD_SIZEOF() and remove sizeof_field() and SIZEOF_FIELD(). I'm a bit surprised that the FIELD_SIZEOF() definition ends up in stddef.h rather than in kernel.h where such things are normally defined. Why is that? ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Wed, 12 Jun 2019 01:08:36 +0530 Shyam Saini wrote: > Currently, there are 3 different macros, namely sizeof_field, SIZEOF_FIELD > and FIELD_SIZEOF which are used to calculate the size of a member of > structure, so to bring uniformity in entire kernel source tree lets use > FIELD_SIZEOF and replace all occurrences of other two macros with this. > > For this purpose, redefine FIELD_SIZEOF in include/linux/stddef.h and > tools/testing/selftests/bpf/bpf_util.h and remove its defination from > include/linux/kernel.h > > In favour of FIELD_SIZEOF, this patch also deprecates other two similar > macros sizeof_field and SIZEOF_FIELD. > > For code compatibility reason, retain sizeof_field macro as a wrapper macro > to FIELD_SIZEOF As Alexey has pointed out, C structs and unions don't have fields - they have members. So this is an opportunity to switch everything to a new member_sizeof(). What do people think of that and how does this impact the patch footprint? ___ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH V2] include: linux: Regularise the use of FIELD_SIZEOF macro
On Wed, Jun 12, 2019 at 01:08:36AM +0530, Shyam Saini wrote: > In favour of FIELD_SIZEOF, this patch also deprecates other two similar > macros sizeof_field and SIZEOF_FIELD. > > For code compatibility reason, retain sizeof_field macro as a wrapper macro > to FIELD_SIZEOF Can you explain this part? First sentence says you want to remove sizeof_field, and the second says you're keeping it? I thought the point was to switch all of these to FIELD_SIZEOF()? -Kees > > Signed-off-by: Shyam Saini > --- > Changelog: > > V1->V2 > - Consolidate previous patch 1 and 2 into single patch > - For code compatibility reason, retain sizeof_field macro as a > wrapper macro to FIELD_SIZEOF > > arch/arm64/include/asm/processor.h | 10 +- > arch/mips/cavium-octeon/executive/cvmx-bootmem.c | 9 + > drivers/gpu/drm/i915/gvt/scheduler.c | 2 +- > drivers/net/ethernet/mellanox/mlxsw/spectrum_fid.c | 4 ++-- > fs/befs/linuxvfs.c | 2 +- > fs/ext2/super.c| 2 +- > fs/ext4/super.c| 2 +- > fs/freevxfs/vxfs_super.c | 2 +- > fs/orangefs/super.c| 2 +- > fs/ufs/super.c | 2 +- > include/linux/kernel.h | 9 - > include/linux/slab.h | 2 +- > include/linux/stddef.h | 17 ++--- > kernel/fork.c | 2 +- > kernel/utsname.c | 2 +- > net/caif/caif_socket.c | 2 +- > net/core/skbuff.c | 2 +- > net/ipv4/raw.c | 2 +- > net/ipv6/raw.c | 2 +- > net/sctp/socket.c | 4 ++-- > tools/testing/selftests/bpf/bpf_util.h | 22 > +++--- > virt/kvm/kvm_main.c| 2 +- > 22 files changed, 58 insertions(+), 47 deletions(-) > > diff --git a/arch/arm64/include/asm/processor.h > b/arch/arm64/include/asm/processor.h > index fcd0e691b1ea..ace906d887cc 100644 > --- a/arch/arm64/include/asm/processor.h > +++ b/arch/arm64/include/asm/processor.h > @@ -164,13 +164,13 @@ static inline void > arch_thread_struct_whitelist(unsigned long *offset, > unsigned long *size) > { > /* Verify that there is no padding among the whitelisted fields: */ > - BUILD_BUG_ON(sizeof_field(struct thread_struct, uw) != > - sizeof_field(struct thread_struct, uw.tp_value) + > - sizeof_field(struct thread_struct, uw.tp2_value) + > - sizeof_field(struct thread_struct, uw.fpsimd_state)); > + BUILD_BUG_ON(FIELD_SIZEOF(struct thread_struct, uw) != > + FIELD_SIZEOF(struct thread_struct, uw.tp_value) + > + FIELD_SIZEOF(struct thread_struct, uw.tp2_value) + > + FIELD_SIZEOF(struct thread_struct, uw.fpsimd_state)); > > *offset = offsetof(struct thread_struct, uw); > - *size = sizeof_field(struct thread_struct, uw); > + *size = FIELD_SIZEOF(struct thread_struct, uw); > } > > #ifdef CONFIG_COMPAT > diff --git a/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > b/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > index ba8f82a29a81..44b506a14666 100644 > --- a/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > +++ b/arch/mips/cavium-octeon/executive/cvmx-bootmem.c > @@ -45,13 +45,6 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc; > /* See header file for descriptions of functions */ > > /** > - * This macro returns the size of a member of a structure. > - * Logically it is the same as "sizeof(s::field)" in C++, but > - * C lacks the "::" operator. > - */ > -#define SIZEOF_FIELD(s, field) sizeof(((s *)NULL)->field) > - > -/** > * This macro returns a member of the > * cvmx_bootmem_named_block_desc_t structure. These members can't > * be directly addressed as they might be in memory not directly > @@ -65,7 +58,7 @@ static struct cvmx_bootmem_desc *cvmx_bootmem_desc; > #define CVMX_BOOTMEM_NAMED_GET_FIELD(addr, field)\ > __cvmx_bootmem_desc_get(addr, \ > offsetof(struct cvmx_bootmem_named_block_desc, field), \ > - SIZEOF_FIELD(struct cvmx_bootmem_named_block_desc, field)) > + FIELD_SIZEOF(struct cvmx_bootmem_named_block_desc, field)) > > /** > * This function is the implementation of the get macros defined > diff --git a/drivers/gpu/drm/i915/gvt/scheduler.c > b/drivers/gpu/drm/i915/gvt/scheduler.c > index 0f919f0a43d4..820f95a52542 100644 > --- a/drivers/gpu/drm/i915/gvt/scheduler.c > +++ b/drivers/gpu/drm/i915/gvt/scheduler.c > @@