Re: [PATCH v2 3/7] x86/sev: add support for RMPOPT instruction

From: Kalra, Ashish

Date: Mon Mar 02 2026 - 18:30:53 EST


Hello Dave,

On 3/2/2026 4:57 PM, Dave Hansen wrote:

>> + set_current_state(TASK_INTERRUPTIBLE);
>> + schedule();
>> + }
>> +
>> + return 0;
>> +}
>> +
>> +static void rmpopt_all_physmem(void)
>> +{
>> + if (rmpopt_task)
>> + wake_up_process(rmpopt_task);
>> +}
>
> Wait a sec, doesn't this just run all the time? It'll be doing an RMPOPT
> on some forever.

The rmpopt_kthread will be sleeping, till it is woken explicitly by wake_up_process() here.

When the schedule() function is called with the state as TASK_INTERRUPTIBLE or TASK_UNINTERRUPTIBLE,
an additional step is performed: the currently executing process is moved off the run queue before
another process is scheduled. The effect of this is the executing process goes to sleep,
as it no longer is on the run queue. Hence, it never is scheduled by the scheduler.

The thread would then be woken up by calling wake_up_process().

I believe, this is probably the simplest way of sleeping and waking in the kernel.

Thanks,
Ashish