mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: Pierre Habouzit <pierre.habouzit@intersec.com>
Cc: linux-kernel@vger.kernel.org, Avi Kivity <avi@qumranet.com>,
	Ingo Molnar <mingo@elte.hu>
Subject: Re: [PATCH] sched: allow preempt notifiers to self-unregister.
Date: Fri, 16 Dec 2011 18:09:45 +0100	[thread overview]
Message-ID: <1324055385.18942.109.camel@twins> (raw)
In-Reply-To: <1324052151-3714-1-git-send-email-pierre.habouzit@intersec.com>

On Fri, 2011-12-16 at 17:15 +0100, Pierre Habouzit wrote:

>   As a background, this need is because I have some kind of module code
>   that uses this facility to evaluate how many of a group of threads are
>   concurrently running (to regulate a pool of threads).

Typically such stuff is only merged along with whomever uses it.

>   Hence I install those callbacks for the thread registering themselves
>   and want to keep them until the thread dies. Sadly I have no way to
>   unregister those callbacks right now, but for horrible hacks (involving
>   private delayed queues processed regularly walked to kfree() the
>   structures referencing pids that are dead, urgh).

kfree_rcu() is the 'normal' way to cheat your way out of this.

> diff --git a/kernel/sched.c b/kernel/sched.c
> index d6b149c..2653169 100644
> --- a/kernel/sched.c
> +++ b/kernel/sched.c
> @@ -3106,7 +3106,7 @@ static void fire_sched_in_preempt_notifiers(struct task_struct *curr)
>  	struct preempt_notifier *notifier;
>  	struct hlist_node *node;
>  
> -	hlist_for_each_entry(notifier, node, &curr->preempt_notifiers, link)
> +	hlist_for_each_entry_safe(notifier, node, &curr->preempt_notifiers, link)
>  		notifier->ops->sched_in(notifier, raw_smp_processor_id());
>  }
>  
> @@ -3117,7 +3117,7 @@ fire_sched_out_preempt_notifiers(struct task_struct *curr,
>  	struct preempt_notifier *notifier;
>  	struct hlist_node *node;
>  
> -	hlist_for_each_entry(notifier, node, &curr->preempt_notifiers, link)
> +	hlist_for_each_entry_safe(notifier, node, &curr->preempt_notifiers, link)
>  		notifier->ops->sched_out(notifier, next);
>  }

This adds to scheduler hot paths, it needs very good justification.


  reply	other threads:[~2011-12-16 17:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-16 16:15 Pierre Habouzit
2011-12-16 17:09 ` Peter Zijlstra [this message]
2011-12-16 17:25   ` Pierre Habouzit
2011-12-16 17:33     ` Peter Zijlstra
2011-12-16 17:42       ` Pierre Habouzit
2011-12-18  9:10 ` Avi Kivity
2011-12-19 10:26   ` Pierre Habouzit

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=1324055385.18942.109.camel@twins \
    --to=peterz@infradead.org \
    --cc=avi@qumranet.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=pierre.habouzit@intersec.com \
    /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®