On 6/6/2025 2:42 PM, David Hildenbrand wrote: > On 05.06.25 17:37, Fuad Tabba wrote: >> This patch enables support for shared memory in guest_memfd, including >> mapping that memory from host userspace. >> >> This functionality is gated by the KVM_GMEM_SHARED_MEM Kconfig option, >> and enabled for a given instance by the GUEST_MEMFD_FLAG_SUPPORT_SHARED >> flag at creation time. >> >> Co-developed-by: Ackerley Tng <ackerleytng@xxxxxxxxxx> >> Signed-off-by: Ackerley Tng <ackerleytng@xxxxxxxxxx> >> Signed-off-by: Fuad Tabba <tabba@xxxxxxxxxx> >> --- > > [...] > >> +static bool kvm_gmem_supports_shared(struct inode *inode) >> +{ >> + u64 flags; >> + >> + if (!IS_ENABLED(CONFIG_KVM_GMEM_SHARED_MEM)) >> + return false; >> + >> + flags = (u64)inode->i_private; > > Can probably do above > > const u64 flags = (u64)inode->i_private; > >> + >> + return flags & GUEST_MEMFD_FLAG_SUPPORT_SHARED; >> +} >> + I agree on using const will have some safety, clarity and optimization. I did not understand why don't we directly check the flags like... return (u64)inode->i_private & GUEST_MEMFD_FLAG_SUPPORT_SHARED; ...which is more concise. Thanks, Shivank