From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Aaron Lu <aaron.lu@intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH] sched: Introduce per-mm/cpu concurrency id state
Date: Fri, 31 Mar 2023 19:56:09 -0400 [thread overview]
Message-ID: <5efc39c5-865b-1c0f-e22d-dc79c67dbcf2@efficios.com> (raw)
In-Reply-To: <20230331083830.GA186694@ziqianlu-desk2>
On 2023-03-31 04:38, Aaron Lu wrote:
> On Thu, Mar 30, 2023 at 07:09:11PM -0400, Mathieu Desnoyers wrote:
>
>> void sched_mm_cid_exit_signals(struct task_struct *t)
>> {
>> struct mm_struct *mm = t->mm;
>> - unsigned long flags;
>> + struct rq *rq = this_rq();
>
> Got many below messages due to the above line:
>
> [ 19.294089] BUG: using smp_processor_id() in preemptible [00000000] code: kworker/u449:0/1621
>
>> + struct rq_flags rf;
>>
>> if (!mm)
>> return;
>> - local_irq_save(flags);
>> + rq_lock_irqsave(rq, &rf);
>> mm_cid_put(mm, t->mm_cid);
>> t->mm_cid = -1;
>> t->mm_cid_active = 0;
>> - local_irq_restore(flags);
>> + rq_unlock_irqrestore(rq, &rf);
>> }
>>
>> void sched_mm_cid_before_execve(struct task_struct *t)
>> {
>> struct mm_struct *mm = t->mm;
>> - unsigned long flags;
>> + struct rq *rq = this_rq();
>
> Also here;
>
>> + struct rq_flags rf;
>>
>> if (!mm)
>> return;
>> - local_irq_save(flags);
>> + rq_lock_irqsave(rq, &rf);
>> mm_cid_put(mm, t->mm_cid);
>> t->mm_cid = -1;
>> t->mm_cid_active = 0;
>> - local_irq_restore(flags);
>> + rq_unlock_irqrestore(rq, &rf);
>> }
>>
>> void sched_mm_cid_after_execve(struct task_struct *t)
>> {
>> struct mm_struct *mm = t->mm;
>> - unsigned long flags;
>> + struct rq *rq = this_rq();
>
> And here.
>
>> + struct rq_flags rf;
>>
>> if (!mm)
>> return;
>> - local_irq_save(flags);
>> + rq_lock_irqsave(rq, &rf);
>> t->mm_cid = mm_cid_get(mm);
>> t->mm_cid_active = 1;
>> - local_irq_restore(flags);
>> + rq_unlock_irqrestore(rq, &rf);
>> rseq_set_notify_resume(t);
>> }
>
> I used below diff to get rid of these messages without understanding the
> purpose of these functions:
I'll fold this fix into the next round, thanks!
Mathieu
>
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index f07b87d155bd..7194c29f3c91 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -11444,45 +11444,57 @@ void sched_mm_cid_migrate_to(struct rq *dst_rq, struct task_struct *t, int src_c
> void sched_mm_cid_exit_signals(struct task_struct *t)
> {
> struct mm_struct *mm = t->mm;
> - struct rq *rq = this_rq();
> struct rq_flags rf;
> + struct rq *rq;
>
> if (!mm)
> return;
> +
> + preempt_disable();
> + rq = this_rq();
> rq_lock_irqsave(rq, &rf);
> mm_cid_put(mm, t->mm_cid);
> t->mm_cid = -1;
> t->mm_cid_active = 0;
> rq_unlock_irqrestore(rq, &rf);
> + preempt_enable();
> }
>
> void sched_mm_cid_before_execve(struct task_struct *t)
> {
> struct mm_struct *mm = t->mm;
> - struct rq *rq = this_rq();
> struct rq_flags rf;
> + struct rq *rq;
>
> if (!mm)
> return;
> +
> + preempt_disable();
> + rq = this_rq();
> rq_lock_irqsave(rq, &rf);
> mm_cid_put(mm, t->mm_cid);
> t->mm_cid = -1;
> t->mm_cid_active = 0;
> rq_unlock_irqrestore(rq, &rf);
> + preempt_enable();
> }
>
> void sched_mm_cid_after_execve(struct task_struct *t)
> {
> struct mm_struct *mm = t->mm;
> - struct rq *rq = this_rq();
> struct rq_flags rf;
> + struct rq *rq;
>
> if (!mm)
> return;
> +
> + preempt_disable();
> + rq = this_rq();
> rq_lock_irqsave(rq, &rf);
> t->mm_cid = mm_cid_get(mm);
> t->mm_cid_active = 1;
> rq_unlock_irqrestore(rq, &rf);
> + preempt_enable();
> rseq_set_notify_resume(t);
> }
>
--
Mathieu Desnoyers
EfficiOS Inc.
https://www.efficios.com
next prev parent reply other threads:[~2023-03-31 23:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-30 23:09 Mathieu Desnoyers
2023-03-31 8:38 ` Aaron Lu
2023-03-31 23:56 ` Mathieu Desnoyers [this message]
2023-03-31 8:52 ` Aaron Lu
2023-04-03 18:17 ` Mathieu Desnoyers
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5efc39c5-865b-1c0f-e22d-dc79c67dbcf2@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=aaron.lu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®