~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/resume_user_mode.h

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /* SPDX-License-Identifier: GPL-2.0-only */
  2 
  3 #ifndef LINUX_RESUME_USER_MODE_H
  4 #define LINUX_RESUME_USER_MODE_H
  5 
  6 #include <linux/sched.h>
  7 #include <linux/task_work.h>
  8 #include <linux/memcontrol.h>
  9 #include <linux/rseq.h>
 10 #include <linux/blk-cgroup.h>
 11 
 12 /**
 13  * set_notify_resume - cause resume_user_mode_work() to be called
 14  * @task:               task that will call resume_user_mode_work()
 15  *
 16  * Calling this arranges that @task will call resume_user_mode_work()
 17  * before returning to user mode.  If it's already running in user mode,
 18  * it will enter the kernel and call resume_user_mode_work() soon.
 19  * If it's blocked, it will not be woken.
 20  */
 21 static inline void set_notify_resume(struct task_struct *task)
 22 {
 23         if (!test_and_set_tsk_thread_flag(task, TIF_NOTIFY_RESUME))
 24                 kick_process(task);
 25 }
 26 
 27 
 28 /**
 29  * resume_user_mode_work - Perform work before returning to user mode
 30  * @regs:               user-mode registers of @current task
 31  *
 32  * This is called when %TIF_NOTIFY_RESUME has been set.  Now we are
 33  * about to return to user mode, and the user state in @regs can be
 34  * inspected or adjusted.  The caller in arch code has cleared
 35  * %TIF_NOTIFY_RESUME before the call.  If the flag gets set again
 36  * asynchronously, this will be called again before we return to
 37  * user mode.
 38  *
 39  * Called without locks.
 40  */
 41 static inline void resume_user_mode_work(struct pt_regs *regs)
 42 {
 43         clear_thread_flag(TIF_NOTIFY_RESUME);
 44         /*
 45          * This barrier pairs with task_work_add()->set_notify_resume() after
 46          * hlist_add_head(task->task_works);
 47          */
 48         smp_mb__after_atomic();
 49         if (unlikely(task_work_pending(current)))
 50                 task_work_run();
 51 
 52 #ifdef CONFIG_KEYS_REQUEST_CACHE
 53         if (unlikely(current->cached_requested_key)) {
 54                 key_put(current->cached_requested_key);
 55                 current->cached_requested_key = NULL;
 56         }
 57 #endif
 58 
 59         mem_cgroup_handle_over_high(GFP_KERNEL);
 60         blkcg_maybe_throttle_current();
 61 
 62         rseq_handle_notify_resume(NULL, regs);
 63 }
 64 
 65 #endif /* LINUX_RESUME_USER_MODE_H */
 66 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php