On Mar 26, 2021, at 09:34, Jann Horn <ja...@google.com> wrote: > On Sun, Feb 21, 2021 at 7:56 PM Chang S. Bae <chang.seok....@intel.com> wrote: >> >> + if (handle_xfirstuse_event(¤t->thread.fpu)) >> + return; > > What happens if handle_xfirstuse_event() fails because vmalloc() > failed in alloc_xstate_buffer()? I think that should probably kill the > task with something like force_sig() - but as far as I can tell, at > the moment, it will instead end up at die(), which should only be used > for kernel bugs.
This question was raised on v1 before [1]. In the end, people suggested to handle the failure, e.g., with tracepoints or stats. So, proposed this on the allocation site: + state_ptr = vmalloc(newsz); + if (!state_ptr) { + trace_x86_fpu_xstate_alloc_failed(fpu); + return -ENOMEM; + } Also, I tried to justify this to Boris [2]: >> Maybe it is possible to backtrack this allocation failure out of #NM >> handling. But the tracepoint can provide a clear context, although limited >> to those using it. > Yes, add it when it is really needed. Not slapping it proactively and > hoping for any potential usage. Let me know if you have a better way. Thanks, Chang [1] https://lore.kernel.org/lkml/c4669d5f-11b8-3879-562c-78a791b86...@intel.com/ [2] https://lore.kernel.org/lkml/20210204131002.ga17...@zn.tnic/