Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp3808234pxu; Mon, 12 Oct 2020 01:25:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwU9FxNupLdX2mPxbH8QDOMoPXI3fnGgbjchWbkiRVmOps4g0WG1Ox8hqDZXhEBRZzR6Wva X-Received: by 2002:a17:906:a192:: with SMTP id s18mr27942573ejy.205.1602491129518; Mon, 12 Oct 2020 01:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602491129; cv=none; d=google.com; s=arc-20160816; b=g1ad/Es/uN/ddbQCr8epB1r+XWPrrRFGKFGdSY1zlTTmolRqswn2FxQK4zGsd2M4wt sCQH87LjocYe6E64A3oBxJhCh2bIfz72LJxf0jB++ea6wsujlZaqqhhgdY+PgBJ9dzq1 2YntcZ6ja3u4ITjwCkXCzRsCGWPU9Y5WFKr1+thuRa3qgJVdsjKfeDk4bv5plrtYEchR HnYLGT2CGD0D+FLH7AlLmrvRwBD6EhLtcmxriB6QevqTVdJbyP4l8utouYm7ApvuB2rK AjItt0+ujdweKSKQxyuJWR8p1r+lHB9MrAnjueOIPCv0TqkAleisgk3TlBredTIoRNyf 9aOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:dkim-signature:dkim-signature:date; bh=Oc6GxNvZyhzVd+sRQ9Lj/+rIXB/pm2oFr0J0wwuGklo=; b=PY9zKT2dNW4ELWqKbhObzLf3DxgnIX60L6xrWNxIcxYbNRDYkwhfOP92VgGMM5oDu2 2dgDO9SWUolxG79kM7b+9Dawe++3irpGenawUhUkabBW6iDyCLN0fvTyre/nI25Xxxvl IpItgu8J1DGooksL9SVUxuqPLnPw6KK0iLf2GU21A+0+1Dp7Sump6ZDm4n3rwQuQaW0y xroK963R8VwvIqyyDQTj1UnScZXGptPOOepSEDX3komUI9Rhn9NPG5VYf53aURYyBl8E hSnVBI/LdpPQflTDU2AfGAUvghLGyW5/vHSNwev/g5yfC0EpYuzKkXgs8Z5LLVeAiYB1 PSuQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AaPfabCd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e3si11999627ejt.37.2020.10.12.01.25.04; Mon, 12 Oct 2020 01:25:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=AaPfabCd; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbgJLIVd (ORCPT + 99 others); Mon, 12 Oct 2020 04:21:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38230 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726098AbgJLIVc (ORCPT ); Mon, 12 Oct 2020 04:21:32 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF06EC0613CE; Mon, 12 Oct 2020 01:21:32 -0700 (PDT) Date: Mon, 12 Oct 2020 10:21:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1602490891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oc6GxNvZyhzVd+sRQ9Lj/+rIXB/pm2oFr0J0wwuGklo=; b=AaPfabCd3W3r8sV3ghr//kbp8XY3foRNl/BjtxKdUcSW/7jKk5x3dwXzPzn/N2QevJ5FAr j4KmUq9KnbAmzve34Uolyp8WyejFF2t1oHtMbQt+WuFbxGD7LURYct+3p4hKquDgS4XLrr +FfJrP5PtLXIiCdq9scAwVG6j++nOs1Cro8YaRK1HeMgsU1DG+A3XQE3lXJwsRGSYXq+qT p0oqrUeQuRCkPbEQaVvhuoAnJ/iisoHh8kXuuJY43PlJQtGchTbmfSDW9/aJHdEPYVKRlD mKTDX75kZFboQrnAowFAMXtohQ2fENix9sCKNC7OL1EiZ7+0I7CIaABh+UtbyA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1602490891; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Oc6GxNvZyhzVd+sRQ9Lj/+rIXB/pm2oFr0J0wwuGklo=; b=U1x2dRRGH0h9hNdzp5x/VIgX+WDIWaZ6rACrBk1Ekkn0UzNwaCjOA/SOXkEvP/aO2rrhd3 OSm00B2OiAt/+PAA== From: Sebastian Andrzej Siewior To: Eelco Chaudron Cc: Juri Lelli , 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 Message-ID: <20201012082129.ocod2dlftwais65a@linutronix.de> References: <20201009124759.592550-1-juri.lelli@redhat.com> <20201009154116.a4fcrrm7flxonidd@linutronix.de> <65BBD0B4-2A74-421A-BF81-357CD5F84747@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <65BBD0B4-2A74-421A-BF81-357CD5F84747@redhat.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-10-12 10:14:42 [+0200], Eelco Chaudron wrote: >=20 >=20 > On 9 Oct 2020, at 17:41, Sebastian Andrzej Siewior wrote: >=20 > > 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). > > >=20 > > > 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). > >=20 > > This warning is not limited to PREEMPT_RT it also present upstream since > > commit > > eac87c413bf97 ("net: openvswitch: reorder masks array based on > > usage") > >=20 > > 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() > >=20 > > (means I don't know but it looks like coming from NAPI). > >=20 > > 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. > >=20 > > -> You need to ensure that there is only one writer at a time. > >=20 > > 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'. >=20 > I=E2=80=99m not too familiar with the RT kernel, but in the none RT kerne= l, 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 l= ock > 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 ca= se? > //Eelco Sebastian