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.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, 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 8EF2CC3A5A0 for ; Sun, 19 Apr 2020 22:23:38 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A42820B1F for ; Sun, 19 Apr 2020 22:23:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A42820B1F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=acm.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AA51C8E0005; Sun, 19 Apr 2020 18:23:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A55698E0003; Sun, 19 Apr 2020 18:23:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9923F8E0005; Sun, 19 Apr 2020 18:23:37 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0075.hostedemail.com [216.40.44.75]) by kanga.kvack.org (Postfix) with ESMTP id 81E8B8E0003 for ; Sun, 19 Apr 2020 18:23:37 -0400 (EDT) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 431E2585D for ; Sun, 19 Apr 2020 22:23:37 +0000 (UTC) X-FDA: 76726032474.22.chess69_270e11725a03 X-HE-Tag: chess69_270e11725a03 X-Filterd-Recvd-Size: 6467 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf11.hostedemail.com (Postfix) with ESMTP for ; Sun, 19 Apr 2020 22:23:36 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id q18so545169pgm.11 for ; Sun, 19 Apr 2020 15:23:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PxxckLMR2d23G7JoN6ozKi6ERyzYCtE5BsAkT8xkLNU=; b=h8gp0rNOwtuhLgUnA47ncRrpP1AjJ0YlIwQd42ze1Ts36FWqZKl7QeskiUrKd07D3v LEQ6wFtkhn8d95pzB7BfmlF9864wyNrfcv5gY99W1NHwSgFOT7Kf7PaEKwEsOoTy3qB0 RiYo6bSgWKjwzyyOYiBaZfswDuhIXSus9fVIkD7E1JNfWG3ZHg6QvxD+CYfX5V1fF5nw tKclh0zY6jRyoUuQnntw7bhAMIRUl5SSXFCgamYwP5i4lLAev9yok+qTYCvXdRfsFvTW JUMR8WvWECDGMzUpiFdI9gYTgewbO0Bm1J1ljHGxWWl5MzDZeCCyklG1kH5RXLqdmrUl eung== X-Gm-Message-State: AGi0PuYKbrhgJWdFtcyXP0a91Gsqva4KLg0ZlSDiLEQANdwsrbwl7ptM XeKztHyfaRxLnrKQjrlB1BA= X-Google-Smtp-Source: APiQypJKXdia+liMhX0/hlemOsS2zbQv5lseIECGPkTjiAMuvfNJzjg5PKXUFzaG+2drmrCSZSz94w== X-Received: by 2002:aa7:9484:: with SMTP id z4mr14283395pfk.144.1587335015542; Sun, 19 Apr 2020 15:23:35 -0700 (PDT) Received: from [100.124.11.78] ([104.129.199.4]) by smtp.gmail.com with ESMTPSA id 135sm26218134pfu.207.2020.04.19.15.23.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 Apr 2020 15:23:34 -0700 (PDT) Subject: Re: [PATCH v2 04/10] block: revert back to synchronous request_queue removal To: Luis Chamberlain , axboe@kernel.dk, viro@zeniv.linux.org.uk, gregkh@linuxfoundation.org, rostedt@goodmis.org, mingo@redhat.com, jack@suse.cz, ming.lei@redhat.com, nstange@suse.de, akpm@linux-foundation.org Cc: 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 References: <20200419194529.4872-1-mcgrof@kernel.org> <20200419194529.4872-5-mcgrof@kernel.org> From: Bart Van Assche Message-ID: <749d56bd-1d66-e47b-a356-8d538e9c99b4@acm.org> Date: Sun, 19 Apr 2020 15:23:31 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.6.0 MIME-Version: 1.0 In-Reply-To: <20200419194529.4872-5-mcgrof@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 4/19/20 12:45 PM, Luis Chamberlain wrote: > +/** > + * blk_put_queue - decrement the request_queue refcount > + * > + * @q: the request_queue structure to decrement the refcount for > + * How about following the example from Documentation/doc-guide/kernel-doc.rst and not leaving a blank line above the function argument documentation? > + * Decrements the refcount to the request_queue kobject, when this reaches ^^ of? > + * 0 we'll have blk_release_queue() called. You should avoid calling > + * this function in atomic context but if you really have to ensure you > + * first refcount the block device with bdgrab() / bdput() so that the > + * last decrement happens in blk_cleanup_queue(). > + */ Is calling bdgrab() and bdput() an option from a context in which it is not guaranteed that the block device is open? Does every context that calls blk_put_queue() also call blk_cleanup_queue()? How about avoiding confusion by changing the last sentence of that comment into something like the following: "The last reference must not be dropped from atomic context. If it is necessary to call blk_put_queue() from atomic context, make sure that that call does not decrease the request queue refcount to zero." > /** > * blk_cleanup_queue - shutdown a request queue > + * > * @q: request queue to shutdown > * How about following the example from Documentation/doc-guide/kernel-doc.rst and not leaving a blank line above the function argument documentation? > * Mark @q DYING, drain all pending requests, mark @q DEAD, destroy and > * put it. All future requests will be failed immediately with -ENODEV. > + * > + * You should not call this function in atomic context. If you need to > + * refcount a request_queue in atomic context, instead refcount the > + * block device with bdgrab() / bdput(). Surrounding blk_cleanup_queue() with bdgrab() / bdput() does not help. This blk_cleanup_queue() must not be called from atomic context. > /** > - * __blk_release_queue - release a request queue > - * @work: pointer to the release_work member of the request queue to be released > + * blk_release_queue - release a request queue > + * > + * This function is called as part of the process when a block device is being > + * unregistered. Releasing a request queue starts with blk_cleanup_queue(), > + * which set the appropriate flags and then calls blk_put_queue() as the last > + * step. blk_put_queue() decrements the reference counter of the request queue > + * and once the reference counter reaches zero, this function is called to > + * release all allocated resources of the request queue. > * > - * Description: > - * This function is called when a block device is being unregistered. The > - * process of releasing a request queue starts with blk_cleanup_queue, which > - * set the appropriate flags and then calls blk_put_queue, that decrements > - * the reference counter of the request queue. Once the reference counter > - * of the request queue reaches zero, blk_release_queue is called to release > - * all allocated resources of the request queue. > + * This function can sleep, and so we must ensure that the very last > + * blk_put_queue() is never called from atomic context. > + * > + * @kobj: pointer to a kobject, who's container is a request_queue > */ Please follow the style used elsewhere in the kernel and move function argument documentation just below the line with the function name. Thanks, Bart.