Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1539403ybz; Thu, 30 Apr 2020 00:53:30 -0700 (PDT) X-Google-Smtp-Source: APiQypL8g9+baP2Ri1TfxRPCJbTb5hH30FTwLaL6yOLPpZ7TCI6/3cMGCeaWMWqpqS4lgNnXEpD/ X-Received: by 2002:a05:6402:2293:: with SMTP id cw19mr1458934edb.351.1588233209920; Thu, 30 Apr 2020 00:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588233209; cv=none; d=google.com; s=arc-20160816; b=k1pLw73wMPC/XHJ5az+YcJUMN17rWrWBggT42UfKEBnBzMx9hALSQAhJTRjS1JeTLf kauBwqyLRGnq2qLdmoh0E2zxDRNqS8YwJ1XKmaw5A68rnGc9uG02m5K3vR3gqQSuq0xD UCHM1ZmF34+gbx+cHoJKQiWZbo3xLOdNOrpdE7jSdKCkCA2klsF9TSIgr+2G+G4aWUXc QPUuohQkJNUTW16heFkGRBsMJK8bw28A8JAmuhuaErXYhgsHxis7fDh77uR/2HaiNlPL UrMdtgtFiiC0ASU/CiZvuAy4DRBhqjeOkkBGjnF1Iiu0Cdi+23LIrd0qcQ0V/MRt0QKf T0Aw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=pLDutk4wbmpMCH/umkH9WAYAlTySTFnkRecmVU+0E0s=; b=v7z3cmDT75gwGV//QKp2EV2HKRzcDpcqNnFvrq5KAZRUUAFKJ4jh04EiCL/s5vQuD5 snZIQMrVko5hijW4YeHNTsDclOFE+/4/DGctHdAjK5ZqtAQLM7w8DT+4Qtwtal6NVbyW CFLxVBChdhQCntlEFiCpjWnAAa7AxPzb6mzycV+ww3lxGu4D7PAi2fe7S5uyrnvz1ZKo 0exBwNO/HIKD81KEgIX8EfF9k+RiYE0pNtALg7LwAFaas2LKxL+jayDKZIO8EL9CGvrF ICsGYuGw3Ly4T6sGOu2WOHYtB9mQFAVBson+CBnwew2G8aGqTlG+T90ckeJls2nneWuh xvJw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=kqSSjeZ+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si5152124edi.150.2020.04.30.00.53.06; Thu, 30 Apr 2020 00:53: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=@google.com header.s=20161025 header.b=kqSSjeZ+; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726546AbgD3HvS (ORCPT + 99 others); Thu, 30 Apr 2020 03:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726358AbgD3HvR (ORCPT ); Thu, 30 Apr 2020 03:51:17 -0400 Received: from mail-yb1-xb44.google.com (mail-yb1-xb44.google.com [IPv6:2607:f8b0:4864:20::b44]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FC76C035494 for ; Thu, 30 Apr 2020 00:51:17 -0700 (PDT) Received: by mail-yb1-xb44.google.com with SMTP id e16so496037ybn.7 for ; Thu, 30 Apr 2020 00:51:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pLDutk4wbmpMCH/umkH9WAYAlTySTFnkRecmVU+0E0s=; b=kqSSjeZ+rI8gARW5nI9FUaRItjm5CqM0fjB5XI6W+lEAOiIkavNEQoguWYtY1vtJTE tSQg1dAfckJKYYcqEmELyk7FoGt4b5fHt2oVsRrBVT+CV39NIQwRObSDJwV/hTaGh9C3 pjqB2w6Uk4Ax3XPNbh5hczFlpH7xshwCWI0i2X7/S2lduFTY/PRHRtV4ZY3Rjl3Okj9a 3g0Z685XhVwmIO6Y5Mhu9JJrKzHuf2I9EEIShxkLltG1anSirqdZOvQaUUTVfNdQlCLS hZI5GleQ5MLfCOHux7SHLBKKGdc4bMHLzbBTPVlolyXibu61qM5jWF/2xaJBSFvG2KIW 80nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pLDutk4wbmpMCH/umkH9WAYAlTySTFnkRecmVU+0E0s=; b=tKyitpxaqoXMZc4Whgj6bG/oyf4Qx5/w7SJlY0eGDiQEzeT7177dnrFAwHDhTv70Pf LwLJBsPSYqDtlS2HbcZyEKrnsQsqdeBx/Hm38VBmxLPGQnfmXKQKbp/dzV1YQJkvwk5v GqDzPPwQ+lOSUhkIRQeajdSkfKB4QmPafUniA33OyaK/BOPpXTx8lFIQNiZWw9rq1w96 pb0CfE+hArJMGzpLmGDgh2BFv45CmXjo//srXS4nQqA5rCKeiq31iuwN3rK+a+8iW2zj HQWXmYzXMb0Z+8YNUrkTmwnprQj7du81uOuqcj6FrJhMAlKg6cSnQ6581ZvjEPB3XZ/y 6c3A== X-Gm-Message-State: AGi0PuapmXx/Jr2vbqVlDXKPMWsqUlYgcj5MkF4kcO5UzLl5+1W+5QHB SeW8Ky1QKpQcITpBxpjIKiSsRlTFfk2B+lRS3qXj2Q== X-Received: by 2002:a25:cc48:: with SMTP id l69mr3629847ybf.459.1588233075137; Thu, 30 Apr 2020 00:51:15 -0700 (PDT) MIME-Version: 1.0 References: <20200429153258.563269446@infradead.org> <20200429153549.006661686@infradead.org> <20200430072847.GA68379@localhost.localdomain> In-Reply-To: <20200430072847.GA68379@localhost.localdomain> From: Michel Lespinasse Date: Thu, 30 Apr 2020 00:51:02 -0700 Message-ID: Subject: Re: [RFC][PATCH 1/7] rbtree: Add generic add and find helpers To: Juri Lelli Cc: Peter Zijlstra , LKML , Davidlohr Bueso , Ingo Molnar , Thomas Gleixner , Oleg Nesterov , irogers@google.com, Vincent Guittot Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 30, 2020 at 12:28 AM Juri Lelli wrote: > > --- a/include/linux/rbtree.h > > +++ b/include/linux/rbtree.h > > @@ -141,12 +141,18 @@ static inline void rb_insert_color_cache > > rb_insert_color(node, &root->rb_root); > > } > > > > -static inline void rb_erase_cached(struct rb_node *node, > > +static inline bool rb_erase_cached(struct rb_node *node, > > struct rb_root_cached *root) > > { > > - if (root->rb_leftmost == node) > > + bool leftmost = false; > > + > > + if (root->rb_leftmost == node) { > > root->rb_leftmost = rb_next(node); > > Think we need > > if (root->rb_leftmost) > > > + leftmost = true; > > DEADLINE crashes w/o that. I think Peter's code is correct; after removing the only node in an rbtree rb_leftmost should be NULL. The issue appears to be in dequeue_pushable_dl_task unconditionally dereferencing the pointer returned by rb_first_cached(), which may be NULL. I'm not sure what the correct behavior is though, i.e. what dl_rq->earliest_dl.next should be set to if the rbtree ends up empty. Current code (before Peter's changes) preserves the existing dl_rq->earliest_dl.next value in that case, which seems very weird to me (and worthy of a comment if it's correct).