On Tue, Feb 16, 2021 at 6:02 PM Jan Kara <jack@xxxxxxx> wrote: > > Hi Amir! > > Looking at the patches I've got one idea: > > Currently you have fsnotify_event like: > > struct fsnotify_event { > struct list_head list; > unsigned int key; > unsigned int next_bucket; > }; > > And 'list' is used for hashed queue list, next_bucket is used to simulate > single queue out of all the individual lists. The option I'm considering > is: > > struct fsnotify_event { > struct list_head list; > struct fsnotify_event *hash_next; > unsigned int key; > }; > > So 'list' would stay to be used for the single queue of events like it was > before your patches. 'hash_next' would be used for list of events in the > hash chain. The advantage of this scheme would be somewhat more obvious > handling, I can agree to that. > also we can handle removal of permission events (they won't be > hashed so there's no risk of breaking hash-chain in the middle, removal > from global queue is easy as currently). Ok. but I do not really see a value in hashing non-permission events for high priority groups, so this is not a strong argument. > The disadvantage is increase of > event size by one pointer on 64-bit but I think we can live with that. What > do you think? Given the round size of fixes size events in v5.10, that would be a shame: ls -l /sys/kernel/slab/*notify*event lrwxrwxrwx 1 root root 0 Feb 17 12:23 /sys/kernel/slab/fanotify_fid_event -> :0000064 lrwxrwxrwx 1 root root 0 Feb 17 12:23 /sys/kernel/slab/fanotify_path_event -> :0000056 lrwxrwxrwx 1 root root 0 Feb 17 12:23 /sys/kernel/slab/fanotify_perm_event -> :0000064 Counter proposal: struct fsnotify_event { struct list_head list; struct fsnotify_event *hash_next; unsigned int key; u32 mask; }; It is quite strange that mask is a member of struct fanotify_event and struct inotify_event_info to begin with. Moving the mask member to struct fsnotify_event like that is not going to change the resulting inotify/fanotify event size. We can actually squeeze fanotify_event_type into 2 low bits of pid pointer, and reduce the size of all fanotify events by one pointer, because FANOTIFY_EVENT_TYPE_OVERFLOW is nice to have. The overflow event can use FANOTIFY_EVENT_TYPE_PATH with a NULL path values (as early versions of the patch did). This is not worth doing with current round event size, IMO. Thanks, Amir.