From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.5 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E63D0C3815B for ; Wed, 15 Apr 2020 12:34:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id B4EC220737 for ; Wed, 15 Apr 2020 12:34:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B4EC220737 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6358F8E0019; Wed, 15 Apr 2020 08:34:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 60C8A8E0001; Wed, 15 Apr 2020 08:34:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4D4768E0019; Wed, 15 Apr 2020 08:34:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0145.hostedemail.com [216.40.44.145]) by kanga.kvack.org (Postfix) with ESMTP id 361AD8E0001 for ; Wed, 15 Apr 2020 08:34:38 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id DE35C2826 for ; Wed, 15 Apr 2020 12:34:37 +0000 (UTC) X-FDA: 76710032994.11.stick93_b497fc812a1e X-HE-Tag: stick93_b497fc812a1e X-Filterd-Recvd-Size: 4851 Received: from mail-pf1-f193.google.com (mail-pf1-f193.google.com [209.85.210.193]) by imf05.hostedemail.com (Postfix) with ESMTP for ; Wed, 15 Apr 2020 12:34:37 +0000 (UTC) Received: by mail-pf1-f193.google.com with SMTP id c138so1456935pfc.0 for ; Wed, 15 Apr 2020 05:34:37 -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:user-agent; bh=rcRovzoWQ44rccZ9H/a7flVu7Tih9ve+r3FKd13LlAQ=; b=RGYnz/U4yIeuQM28eby0AQpPXDiQbhJ3WmerbKdDAJSpGUZhk8JU5A6XVIeMouIkNJ /hkvSaCQbS54E04HbsfqW6XAjAPEnjIFmquYyp6R7dedVX0dHEGZCnVLd/Slksop+vo2 5DYSgOJhtcl4n5ugmKlpqghDJX2WaThG6cYsQYqe9RWHzJNlz+zHzhxP7HgIy2Fq6mHJ sOe1VeSdHk7h3cpZHniiiOgmra0Lj+sJtFhO3y3D7FvaGPUR1TVeuoiKuS5MNxthf7T3 XEL788002Y8FEEoAd9ThNBOs1HnWlnUL2nK1EIB1QXV3uRTHf832R5RfPPiaTlx5MEUe cr5Q== X-Gm-Message-State: AGi0PuZP8LuqRLx4EGAVHy7NoKmhmNbuaK+r+ismmTjwN0utRS/MhVR1 L39m5I9i+LvCrBtrlL2KG6U= X-Google-Smtp-Source: APiQypKeqxCW3QQL5aO52Dw6wP6HdxhoJjvtMA6kum1OCbDCHdbtO6A7AQ4QxcYQpPoWr42KEAvvmg== X-Received: by 2002:a63:cd08:: with SMTP id i8mr22905838pgg.55.1586954076359; Wed, 15 Apr 2020 05:34:36 -0700 (PDT) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id o15sm12562445pgj.60.2020.04.15.05.34.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Apr 2020 05:34:35 -0700 (PDT) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 1649340277; Wed, 15 Apr 2020 12:34:34 +0000 (UTC) Date: Wed, 15 Apr 2020 12:34:34 +0000 From: Luis Chamberlain To: Christoph Hellwig Cc: axboe@kernel.dk, viro@zeniv.linux.org.uk, bvanassche@acm.org, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org, mhocko@suse.com, yukuai3@huawei.com, linux-block@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Omar Sandoval , Hannes Reinecke , Michal Hocko Subject: Re: [PATCH 3/5] blktrace: refcount the request_queue during ioctl Message-ID: <20200415123434.GU11244@42.do-not-panic.com> References: <20200414041902.16769-1-mcgrof@kernel.org> <20200414041902.16769-4-mcgrof@kernel.org> <20200414154044.GB25765@infradead.org> <20200415061649.GS11244@42.do-not-panic.com> <20200415071425.GA21099@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200415071425.GA21099@infradead.org> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Wed, Apr 15, 2020 at 12:14:25AM -0700, Christoph Hellwig wrote: > On Wed, Apr 15, 2020 at 06:16:49AM +0000, Luis Chamberlain wrote: > > The BLKTRACESETUP above works on request_queue which later > > LOOP_CTL_DEL races on and sweeps the debugfs dir underneath us. > > If you use this commit alone though, this doesn't fix the race issue > > however, and that's because of both still the debugfs_lookup() use > > and that we're still using asynchronous removal at this point. > > > > refcounting will just ensure we don't take the request_queue underneath > > our noses. > > > > Should I just add this to the commit log? > > That sounds much more useful than the trace. > > Btw, Isn't blk_get_queue racy as well? Shouldn't we check > blk_queue_dying after getting the reference and undo it if the queue is > indeeed dying? Yes that race should be possible: bool blk_get_queue(struct request_queue *q) { if (likely(!blk_queue_dying(q))) { ----------> we can get the queue to go dying here <--------- __blk_get_queue(q); return true; } return false; } EXPORT_SYMBOL(blk_get_queue); I'll pile up a fix. I've also considered doing a full review of callers outside of the core block layer using it, and maybe just unexporting this. It was originally exported due to commit d86e0e83b ("block: export blk_{get,put}_queue()") to fix a scsi bug, but I can't find such respective fix. I suspec that using bdgrab()/bdput() seems more likely what drivers should be using. That would allow us to keep this functionality internal. Think that's worthy review? Luis