mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Eelco Chaudron <echaudro@redhat.com>
Cc: Juri Lelli <juri.lelli@redhat.com>,
	tglx@linutronix.de, linux-rt-users@vger.kernel.org,
	linux-kernel@vger.kernel.org, bristot@redhat.com,
	williams@redhat.com, atheurer@redhat.com
Subject: Re: [PATCH 5.9 RT] net: openvswitch: Fix using smp_processor_id() in preemptible code
Date: Mon, 12 Oct 2020 10:21:29 +0200	[thread overview]
Message-ID: <20201012082129.ocod2dlftwais65a@linutronix.de> (raw)
In-Reply-To: <65BBD0B4-2A74-421A-BF81-357CD5F84747@redhat.com>

On 2020-10-12 10:14:42 [+0200], Eelco Chaudron wrote:
> 
> 
> On 9 Oct 2020, at 17:41, Sebastian Andrzej Siewior wrote:
> 
> > On 2020-10-09 14:47:59 [+0200], Juri Lelli wrote:
> > > This happens because openvswitch/flow_table::flow_lookup() accesses
> > > per-cpu data while being preemptible (and migratable).
> > > 
> > > Fix it by adding get/put_cpu_light(), so that, even if preempted, the
> > > task executing this code is not migrated (operation is also guarded
> > > by
> > > ovs_mutex mutex).
> > 
> > This warning is not limited to PREEMPT_RT it also present upstream since
> > commit
> >    eac87c413bf97 ("net: openvswitch: reorder masks array based on
> > usage")
> > 
> > You should be able to reproduce it there, too.
> > The path ovs_flow_tbl_lookup() -> flow_lookup() is guarded by ovs_lock()
> > I can't say that this true for
> >    ovs_vport_receive() -> ovs_dp_process_packet() ->
> >    ovs_flow_tbl_lookup_stats() -> flow_lookup()
> > 
> > (means I don't know but it looks like coming from NAPI).
> > 
> > Which means u64_stats_update_begin() could have two writers. This must
> > not happen.
> > There are two reader which do u64_stats_fetch_begin_irq(). Disabling
> > interrupts makes no sense since they perform cross-CPU access.
> > 
> > -> You need to ensure that there is only one writer at a time.
> > 
> > If mask_array gains a spinlock_t for writer protection then you can
> > acquire the lock prio grabbing ->masks_usage_cntr. But as of now there
> > is one `ma->syncp'.
> 
> I’m not too familiar with the RT kernel, but in the none RT kernel, this
> function is called in run to completion parts only, hence does not need a
> lock. Actually, this was designed in such a way that it does not need a lock
> at all.

_no_ As explained above, this is not RT specific.
What guaranties that you don't have two flow_lookup() invocations on the
same CPU? You are using u64_stats_update_begin() which must not be
preempted. This means even if preemption is disabled you must not have
another invocation in BH context. This is due to the
write_seqcount_begin() in u64_stats_update_begin().
If preemption / CPU migration is not a problem in the above part, you
can use annotation to disable the warning that led to the warning. But
the u64_stats invocation looks still problematic.

> So maybe this needs a get_cpu() instead of the light variant in the RT case?

> //Eelco

Sebastian

  reply	other threads:[~2020-10-12  8:21 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-09 12:47 Juri Lelli
2020-10-09 15:01 ` Juri Lelli
2020-10-09 15:41 ` Sebastian Andrzej Siewior
2020-10-12  8:14   ` Eelco Chaudron
2020-10-12  8:21     ` Sebastian Andrzej Siewior [this message]
2020-10-12 13:36       ` Eelco Chaudron

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=20201012082129.ocod2dlftwais65a@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=atheurer@redhat.com \
    --cc=bristot@redhat.com \
    --cc=echaudro@redhat.com \
    --cc=juri.lelli@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=williams@redhat.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®