On Fri, Oct 18, 2024 at 05:51:58PM +0100, Al Viro wrote: > Extra cycles where? If anything, I'd expect a too-small-to-measure > speedup due to dereference shifted from path_init() to __set_nameidata(). > Below is literally all it takes to make filename_lookup() treat NULL > as empty-string name. > > NOTE: I'm not talking about forcing the pure by-descriptor case through > the dfd+pathname codepath; not without serious profiling. But treating > AT_FDCWD + NULL by the delta below and passing NULL struct filename to > filename_lookup()? Where do you expect to have the lost cycles on that? [snip] BTW, could you give me a reference to the mail with those objections? I don't see anything in my mailbox, but... Or was that in one of those AT_EMPTY_PATH_NOCHECK (IIRC?) threads? Anyway, what I'm suggesting is 1) teach filename_lookup() to handle NULL struct filename * argument, treating it as "". Trivial and does not impose any overhead on the normal cases. 2) have statx try to recognize AT_EMPTY_PATH, "" and AT_EMPTY_PATH, NULL. If we have that and dfd is *NOT* AT_FDCWD, we have a nice descriptor-based case and can deal with it. If the name is not empty, we have to go for dfd+filename path. Also obvious. Where we get trouble is AT_FDCWD, NULL case. But with (1) we can simply route that to the same dfd+filename path, just passing it NULL for filename. That handles the currently broken case, with very little disruption to anything else. What's more, the logics for "is it NULL or empty with AT_EMPTY_PATH" no longer needs to care about dfd. We can encapsulate it nicely into a function that takes userland pointer + flags and does the following: if no AT_EMPTY_PATH in flags return getname(pointer) if pointer == NULL (same as vfs_empty_path()) return NULL peek at the first byte, if it's '\0' (same as vfs_empty_path()) return NULL name = getname_flags(pointer, LOOKUP_EMPTY) if IS_ERR(name) return name if unlikely(name is empty) putname(name) return NULL return name Then statx() (or anyone who wants similar AT_EMPTY_PATH + NULL semantics) can do this: name = getname_maybe_null(user_pointer, flags) if (!name && dfd >= 0) // or dfd != AT_FDCWD, perhaps do_something_by_fd(dfd, ...) else do_something_by_name(dfd, name, ...) without the bitrot-prone boilerplate.