Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1552815ybz; Thu, 30 Apr 2020 01:10:26 -0700 (PDT) X-Google-Smtp-Source: APiQypLiGfECBc8S2iZ1r1iHwiFMllktfjqbaNr1h7Ywd7rL29MerxQ4e7HSy2Xi9NtuMYhdrMoa X-Received: by 2002:a17:906:18e9:: with SMTP id e9mr1554163ejf.140.1588234226337; Thu, 30 Apr 2020 01:10:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588234226; cv=none; d=google.com; s=arc-20160816; b=GggHq6yQ9P8bjw4PI8pEOCghARPghwNHjm+6CYC3WCjxzZB1tZNJZHpOwVdGI+/dQc rcsj3rDS4G3YlIrLXEHNR6Nik+GvDIdMfoPCvFSPVeZhhhsG+LBRkD1BZcnbiYQCGLxt SCMEYXqhOgdPTTDiDZj8WALSdFkjl/VJIKI2x6CKAssAAjl/LoB99CGyo5zyaJIik6W2 /fL634OS/dOC4KZE1zg9Gt00ebjiQY6aBUH6QaV6TbitYliKzIqHQJ/RrWxE6Ppn+3dr 8PcY/ADOulTJU71zOtUA2XOICtM3gNi54ZBlXZTZIt/huAKZP3SERriIbxQEsLp4Q5di yJNQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gdooSi8kzNzLUkGPoOY/gSrvbDZtHNpV4mw4hssBG2A=; b=LKrcYLzYNq+Gmz5bUmByBidXLzjoRSP+FNqkMvC9IUIpDVB008Dlw4gVrAbQ0yZD/4 ElIe9JwPkOzEpAJy/RcIYQHKk3YUvNk5q3HBTVb2Gam6hyGEgx8IVA8/n+vMGutdcWG1 zB/sf2RtjZczvvkZ283A4fvpT4JMGtXEWdrJafKjycosONg2m2oMV8zRVZ3omL9pRvlv ShXKvSGDufbas/ljsm3EwAG7SOqX9B5C45Yqpdjrypp3OirFy5TKiTT6iYWfsjbw8dop tIKclNs6Wo02rJ2JFwIUW493fc1m/ipsqbqDeq9ju2q9tb3Zo56JEuCdCwMmlfpxIAPq QjHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=enelnxuf; 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=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a23si4677165edy.27.2020.04.30.01.10.02; Thu, 30 Apr 2020 01:10:26 -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=@redhat.com header.s=mimecast20190719 header.b=enelnxuf; 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=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727118AbgD3IHa (ORCPT + 99 others); Thu, 30 Apr 2020 04:07:30 -0400 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:60506 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726689AbgD3IH3 (ORCPT ); Thu, 30 Apr 2020 04:07:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1588234047; 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: in-reply-to:in-reply-to:references:references; bh=gdooSi8kzNzLUkGPoOY/gSrvbDZtHNpV4mw4hssBG2A=; b=enelnxuf1qDBkgUxyCCBHrWElzbCRCNajnzy6TfCAUWcu+ziqJPAGPeopocUp5/zgoEGLf nxizfwRhgvvOM9B44APg+H7NZAqxbwAlGTjwJg0VTlzoYpmMGh/9kX0BOt7MKBu0jVeGEL r7kaPV+rZpLkNIehT4K9H5tT04ogN0Y= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-144-8Qrzqyp4PWOcug6gblnwSw-1; Thu, 30 Apr 2020 04:07:26 -0400 X-MC-Unique: 8Qrzqyp4PWOcug6gblnwSw-1 Received: by mail-wr1-f70.google.com with SMTP id g7so3445061wrw.18 for ; Thu, 30 Apr 2020 01:07:26 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=gdooSi8kzNzLUkGPoOY/gSrvbDZtHNpV4mw4hssBG2A=; b=HNgpZrGt0Tp1CRfNJ83zGEa2lN85ui4RKNYCJpiqccBOT0kpfAxb1SsY9pECOjHQi9 h+h0uw8Wetwu/Fi6rXw33D3mswvEOMYt4bhyRLrqxTgoATHLG+1SL9vr09AN3Uw/s+yb 7Z0g4DcfH1RQqZUapk1BoWE2lDU0CVJdKg7CKpKE3Bhk1pi7qiOFXGciisSpjdC9fQk/ DW8ZZ6KNxPKMx/wgyr9IafmyJ2B07sZltn7aGEp4swJg36maVMEwh4IR2xHPEB/Dl7US um9+QZq8B+VjwLgfyysI4bxfuPov5KNV2CemygoHDP9uzhkhg1xhA70WfIemoOn9sWSI srbQ== X-Gm-Message-State: AGi0PubZAxSzXP9b3hoM9I8UXzz5XuAYpxg92mtygD0MVs65z03ExfUs ak4sNfIGJP8xkVxnF0nikVv/Bchk3KIAqDQW5b6nfNry6v7IljBYIgYJMjpzDQ6nwH9MnB6z2SU wfau6mBXZRFGNxtXwqdswc1vx X-Received: by 2002:adf:ce02:: with SMTP id p2mr2401476wrn.173.1588234045016; Thu, 30 Apr 2020 01:07:25 -0700 (PDT) X-Received: by 2002:adf:ce02:: with SMTP id p2mr2401448wrn.173.1588234044664; Thu, 30 Apr 2020 01:07:24 -0700 (PDT) Received: from localhost.localdomain ([151.29.179.209]) by smtp.gmail.com with ESMTPSA id i17sm11338242wml.23.2020.04.30.01.07.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 01:07:23 -0700 (PDT) Date: Thu, 30 Apr 2020 10:07:21 +0200 From: Juri Lelli To: Michel Lespinasse Cc: Peter Zijlstra , LKML , Davidlohr Bueso , Ingo Molnar , Thomas Gleixner , Oleg Nesterov , irogers@google.com, Vincent Guittot Subject: Re: [RFC][PATCH 1/7] rbtree: Add generic add and find helpers Message-ID: <20200430080721.GC68379@localhost.localdomain> References: <20200429153258.563269446@infradead.org> <20200429153549.006661686@infradead.org> <20200430072847.GA68379@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 30/04/20 00:51, Michel Lespinasse wrote: > 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. Indeed, I've only got the idea that Peter was thinking of using rb_erase_cached return value as an indication that new rb_leftmost is not NULL (and for example perform an update in DEADLINE earliest_dl). I also had the impression that DEADLINE is actually the only consumer of that return value and so we were able to define its semantic. > 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). But, yeah. Fixing things in DEADLINE code works for me as well. We could reset it to 0 (initial value), but I now actually wonder if places where that is consumed are actually OK. Different discussion, though. :-) Thanks, Juri