Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4295622ybb; Mon, 23 Mar 2020 18:01:54 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuc+IRAGgL+CBPXozq/bi1pwyV7qbqk+Y41Vd5LOsO6AS0XreEriINGVWPI5TrutQS792M4 X-Received: by 2002:a05:6830:2391:: with SMTP id l17mr20761617ots.339.1585011714163; Mon, 23 Mar 2020 18:01:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585011714; cv=none; d=google.com; s=arc-20160816; b=ezblD/GXpcAtGXZntAnTivrM3R03fAYnJSrLkkExytiuT7SqpJ6vXm3V5foQcvRHq4 3JK5HwtFkBvE/Sl5SM0Xf03+r8OUvGVzgwGQasQHY/jeSEtGDs/Rr+8uru0XKfOa3G4l 1uCHO1n4GnfNpeJOqW3B8gxAIp4RoBBLDHsXKMtNyzVKh5O1Ui65Gu7YgNuL7BuWKHgX jYqjMeUovcK9LhYQ2NrWZ65YPIVS0WqX84Dc4Wqobo4fdL3vf4XJ/6FxGaE75A3z/0JK YQKyP6G5mJfCRen5fL+4wxiY0Xu26c+xygfkosVoOAh5lqmfGrb58PgJ6lZ0F/HyTm7k lu/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from; bh=FV9Jm0aYcHedipT6ggspZBMC10I67fu+F27SNRjFdj8=; b=c1hurYeROUMkyaAndA3jJJzgxms7qTsSqpG1WOI2rdSApTEPHzkEO90VPzPLg7iu9T hht9XYS5E+bqgDpTphE8TYS0EOM87r54hz/ijEDMbJ37J+Pm9tPx3PYUbvRojwCGr87v kbo3wKFQNZwhufa7o3YUmZWf5j5S4aBVd/EZxq22566E000UkBT6uCRtg+CXgQ4zyuin 2PoEvrsOl6AZTE5VZ+ulPDmBk4WVLZPFY/qlZ59pHpPlLiTxWXoxmxrkl7DYJD6rCNuI j8t/dgQo+k2PxDv4ZQSfsQYVpQ09TeBiUUWrheFO9MbCC2hGnkiqQ+vAtTv6cam3/jtN MjCg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y9si8767330oia.47.2020.03.23.18.01.40; Mon, 23 Mar 2020 18:01:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727090AbgCXBBW (ORCPT + 99 others); Mon, 23 Mar 2020 21:01:22 -0400 Received: from Galois.linutronix.de ([193.142.43.55]:43138 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727031AbgCXBBW (ORCPT ); Mon, 23 Mar 2020 21:01:22 -0400 Received: from p5de0bf0b.dip0.t-ipconnect.de ([93.224.191.11] helo=nanos.tec.linutronix.de) by Galois.linutronix.de with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1jGXwP-0001lB-Rn; Tue, 24 Mar 2020 02:01:14 +0100 Received: by nanos.tec.linutronix.de (Postfix, from userid 1000) id 5C672100292; Tue, 24 Mar 2020 02:01:13 +0100 (CET) From: Thomas Gleixner To: Cong Wang Cc: syzbot , David Miller , Jamal Hadi Salim , Jiri Pirko , Jakub Kicinski , LKML , Linux Kernel Network Developers , syzkaller-bugs , "Paul E . McKenney" Subject: Re: WARNING: ODEBUG bug in tcindex_destroy_work (3) In-Reply-To: References: <000000000000742e9e05a10170bc@google.com> <87a74arown.fsf@nanos.tec.linutronix.de> <87ftdypyec.fsf@nanos.tec.linutronix.de> Date: Tue, 24 Mar 2020 02:01:13 +0100 Message-ID: <875zeuftwm.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1,SHORTCIRCUIT=-0.0001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Cong Wang writes: > On Mon, Mar 23, 2020 at 2:14 PM Thomas Gleixner wrote: >> > We use an ordered workqueue for tc filters, so these two >> > works are executed in the same order as they are queued. >> >> The workqueue is ordered, but look how the work is queued on the work >> queue: >> >> tcf_queue_work() >> queue_rcu_work() >> call_rcu(&rwork->rcu, rcu_work_rcufn); >> >> So after the grace period elapses rcu_work_rcufn() queues it in the >> actual work queue. >> >> Now tcindex_destroy() is invoked via tcf_proto_destroy() which can be >> invoked from preemtible context. Now assume the following: >> >> CPU0 >> tcf_queue_work() >> tcf_queue_work(&r->rwork, tcindex_destroy_rexts_work); >> >> -> Migration >> >> CPU1 >> tcf_queue_work(&p->rwork, tcindex_destroy_work); >> >> So your RCU callbacks can be placed on different CPUs which obviously >> has no ordering guarantee at all. See also: > > Good catch! > > I thought about this when I added this ordered workqueue, but it > seems I misinterpret max_active, so despite we have max_active==1, > more than 1 work could still be queued on different CPU's here. The workqueue is not the problem. it works perfectly fine. The way how the work gets queued is the issue. > I don't know how to fix this properly, I think essentially RCU work > should be guaranteed the same ordering with regular work. But this > seems impossible unless RCU offers some API to achieve that. I don't think that's possible w/o putting constraints on the flexibility of RCU (Paul of course might disagree). I assume that the filters which hang of tcindex_data::perfect and tcindex_data:p must be freed before tcindex_data, right? Refcounting of tcindex_data should do the trick. I.e. any element which you add to a tcindex_data instance takes a refcount and when that is destroyed then the rcu/work callback drops a reference which once it reaches 0 triggers tcindex_data to be freed. Thanks, tglx