netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Florian Westphal <fw@strlen.de>
To: Peter Zijlstra <peterz@infradead.org>
Cc: David Miller <davem@davemloft.net>, fw@strlen.de, netdev@vger.kernel.org
Subject: Re: problem with rtnetlink 'reference' count
Date: Mon, 23 Oct 2017 17:32:00 +0200	[thread overview]
Message-ID: <20171023153200.GA12422@breakpoint.cc> (raw)
In-Reply-To: <20171023142555.GF3165@worktop.lehotels.local>

Peter Zijlstra <peterz@infradead.org> wrote:
>   019a316992ee ("rtnetlink: add reference counting to prevent module unload while dump is in progress")
> 
> And that commit is _completely_ broken.
> 
>  1) it not in fact a refcount, so using refcount_t is silly

Your suggestion is...?

>  2) there is a distinct lack of memory barriers, so we can easily
>     observe the decrement while the msg_handler is still in progress.

I guess you mean it needs:

+	smp_mb__before_atomic();
	refcount_dec(&rtnl_msg_handlers_ref[family]);
?

However, this refcount_dec is misplaced anyway as it would need
to occur from nlcb->done() (the handler function gets stored in socket for
use by next recvmsg), so this change is indeed not helpful at all.

>  3) waiting with a schedule()/yield() loop is complete crap and subject
>     life-locks, imagine doing that rtnl_unregister_all() from a RT task.

Whats the alternative?

Only one I see is to pass THIS_MODULE to hook reg/unreg so we know what module registered the
family for purpose of module get/put but thats going to be messy.

Alternatively we can of course sleep instead of schedule() but that
doesn't appear too appealing either (albeit it is a lot less intrusive).

Any other idea?

  reply	other threads:[~2017-10-23 15:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-23 14:25 problem with rtnetlink 'reference' count Peter Zijlstra
2017-10-23 15:32 ` Florian Westphal [this message]
2017-10-23 16:20   ` Peter Zijlstra
2017-10-23 16:37     ` Florian Westphal
2017-10-23 18:31       ` Peter Zijlstra
2017-10-23 19:37         ` Florian Westphal
2017-10-24  8:33           ` Peter Zijlstra
2017-10-24  9:10             ` Florian Westphal

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=20171023153200.GA12422@breakpoint.cc \
    --to=fw@strlen.de \
    --cc=davem@davemloft.net \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).