Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp559781rwb; Wed, 16 Nov 2022 04:49:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6l+ZbRRyHAYl1AUaKpyFLfzMGe37PQIxnGGkQYx8c/pj7JRoYKRBFKMPv+sJ2GrPJHQmKl X-Received: by 2002:aa7:d6cb:0:b0:467:e2dd:b593 with SMTP id x11-20020aa7d6cb000000b00467e2ddb593mr11267597edr.378.1668602978995; Wed, 16 Nov 2022 04:49:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668602978; cv=none; d=google.com; s=arc-20160816; b=Sgt+a82P81v/Mia2/goSRCerYL4xkwE1KYQSDZTFKlx3vu6wtpQ3/NHZLLvfjj68lq qwToltoSsM01I/pS02XuoZRKFmG7a/oMlFo4Sfv4chixxo2WZ3lNx/CQLYd96eLmA702 n9AGR3Rp8/CUmFlbARTDk2Xoj+yHp3P9d2qCy2RO+eSXqpR20p82SCeZ2Ae5UwCTAUGH AFqsTkHq7bKlZmTdjPQqaqNuPPMIUWVqH2sKXnaNjIxq8VXscZNwzET7omNiAWPHDdR2 ztz3xdserCFbGumsegEdq8M9Yu1IHrO/FeOy1OrnYxRZlsP0LR1a3g5Fv/gOxzmjPaGY zJ0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=bk+C/T4/qxmI8fz9f3r+ra5ioQo+MCfYINLArJ5UDZ8=; b=JpORkv+R0PvG0X661ogQfJn4m+1xvTBYf0CGu9kMfJhlw32eBe9YuqPgFhqZd3LEdz KhBWxxXOoDA7R040CYEMyHKyZUSCxXCrfLeCRW2PaLJlfyHeZeikGZ4+yckPEEjSYuZc fhWyYdQnj+H5nFIfT4cTUY64r+68/4mToQu+e1QdWFbzx/c67q29nPA4rk9+kKQYRrSO hY+pi/zokzbdBt5JlBRmwnRdEho8v2Bv4wFSTVeSNhNJo3jfusxWOYC+98bJjkWe4VDb w44y5wi9ovxyXjapjOK4CMZOPBFPiRuW2P29/QKrnjK2to3S8HR+uGdwH60rE2Xfw2pz RH5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wu10-20020a170906eeca00b007a9e6f0f82fsi12970980ejb.516.2022.11.16.04.49.16; Wed, 16 Nov 2022 04:49:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=gmx.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238894AbiKPM3M (ORCPT + 91 others); Wed, 16 Nov 2022 07:29:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46076 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233212AbiKPM2h (ORCPT ); Wed, 16 Nov 2022 07:28:37 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A46C00; Wed, 16 Nov 2022 04:27:08 -0800 (PST) Received: from [0.0.0.0] ([149.28.201.231]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MBDnC-1ooAV80JrC-00ChQs; Wed, 16 Nov 2022 13:26:52 +0100 Message-ID: <7b2ac1a3-4556-1a37-8442-6b7a51b2dc84@gmx.com> Date: Wed, 16 Nov 2022 20:26:46 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v4 1/3] btrfs: add might_sleep() to some places in update_qgroup_limit_item() Content-Language: en-US To: dsterba@suse.cz Cc: ChenXiaoSong , clm@fb.com, josef@toxicpanda.com, dsterba@suse.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, zhangxiaoxu5@huawei.com, yanaijie@huawei.com, wqu@suse.com References: <20221115171709.3774614-1-chenxiaosong2@huawei.com> <20221115171709.3774614-2-chenxiaosong2@huawei.com> <9b47b291-b1a0-ac0c-2049-b7de6545c26b@gmx.com> <3918175e-dddd-2a55-32c4-c07de78ff4cb@gmx.com> <20221116122440.GN5824@suse.cz> From: Qu Wenruo In-Reply-To: <20221116122440.GN5824@suse.cz> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Provags-ID: V03:K1:6tbCdH+7KgUB7+/d7Dd/K+e2XPQPlo7x3eubLzLl1+f0iDniRvG iB1n8D0xAKlIorr3HdYjLQPBJfJcFntOlZW1sQ906XpLRcYTjCIGXh22v1ns7kEGCrBiD0F jAXKZrgwRNA2QTMZyfi9lJDIReRhJvOsAwrh4DHeKPmhZdHl62UnhrdaHYoJmUwmMsT19p8 0Je7eX6N3PRbhdnxzvP1Q== UI-OutboundReport: notjunk:1;M01:P0:/Igt7b7tEYs=;7SSw3lK/XhJAAsRb8y4dFUVx6dW F9YtIcz4FX3zziQ0S9x8lQmnIGVMYvyx3B+ZNEtQIX1LIVU53xkadzipPzu2H790Krxvzc52n 6aqnhVvr+oAVBqbOAk9mcVy7BTz9NQSym8rO0V6VCGnfg4AmWPqKB8eLYVEtgKdR4w2Wyw3eY keF8xCF9C0vzbwfU2lOBtsK+Ylk7pMPJasCsUr2jQDOucWfsEgpoWwaU6cvYj24PEbFyBjgjj Vhgig3l3XygdiSB4Eqm/qLxws5HcgQMbejsdEEwFXjlJK2SAePw14cZPlXnYEqZWn9NWPPM3n Ub7SneXWEjpXyGCivPU3GGMUyg5mkLKfdsKdMzLMFSSRkCrwJhXZ6XaouHqzyMas465JBhsIP BPKuPj6Y8Bfhl+zxAwPZGnrvopcUfQKJ7RHTfA+JIZ75oYU+xhTVuCtyhJMnY3g8AWOkQsQVm FARuKkoFtRgRGjsm2CxIQwjrCkrlPbIKWnTPT0buCoSMqUdXfjmxPjBosYc29izMPHZC2kurP YSpzSM3RGUDCfzy3v2+wq5UAmDSZECTIMT6uhOZ8t/xZm6aD1Fb/YAfgm3Dd1FUk/xLkzgaww JcmcsjRhm5j1ANTpSchwLtb3SSqqaa7+Z/vM0yiuolX+Xnq2TYkxJy3E/sQ/mYFUZYvTRXXUm Etidz4NP0caxqx+IjgUcayYX4U5q4L/Vj7JC7bOl6MtqR75P/L8O4wovwH1FBOAPnv2vIvGtY FtEsj7YOaBwVjVhDDAl8iULxqbBugqCcoe4fQt2fFDemXqDMBcXdo/XWkmJyTgjHn1vNQqiwK 51iWgeUuqNRXK/k0OnokPjXFIcBROMrZ5oILMNd29SpOX++EgjyMatwI7Nw01xJS17BW9yw6/ IRnbVrTzXB2JtMPRSCtgFLqWqb3j+6re6NmGGvp7FB6rTA8T7mc2Z+xxBpAS9p5kug4yTD3ak q//4y9YPmb3JyTIkCxirEpWoXlk= X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, NICE_REPLY_A,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/11/16 20:24, David Sterba wrote: > On Wed, Nov 16, 2022 at 04:43:50PM +0800, Qu Wenruo wrote: >> >> >> On 2022/11/16 16:09, ChenXiaoSong wrote: >>> 在 2022/11/16 6:48, Qu Wenruo 写道: >>>> Looks good. >>>> >>>> We may want to add more in other locations, but this is really a good >>>> start. >>>> >>>> Reviewed-by: Qu Wenruo >>>> >>>> Thanks, >>>> Qu >>> >>> If I just add might_sleep() in btrfs_alloc_path() and >>> btrfs_search_slot(), is it reasonable? >> >> Adding it to btrfs_search_slot() is definitely correct. >> >> But why for btrfs_alloc_path()? Wouldn't kmem_cache_zalloc() itself >> already do the might_sleep_if() somewhere? >> >> I just looked the call chain, and indeed it is doing the check already: >> >> btrfs_alloc_path() >> |- kmem_cache_zalloc() >> |- kmem_cache_alloc() >> |- __kmem_cache_alloc_lru() >> |- slab_alloc() >> |- slab_alloc_node() >> |- slab_pre_alloc_hook() >> |- might_alloc() >> |- might_sleep_if() > > The call chaing is unconditional so the check will always happen but the > condition itself in might_sleep_if does not recognize GFP_NOFS: > > 34 static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags) > 35 { > 36 return !!(gfp_flags & __GFP_DIRECT_RECLAIM); > 37 } > > #define GFP_NOFS (__GFP_RECLAIM | __GFP_IO) > > And I think the qgroup limit was exactly a spin lock over btrfs_path_alloc so > it did not help. An might_sleep() inside btrfs_path_alloc() is a very minimal > but reliable check we could add, the paths are used in many places so it would > increase the coverage. OK, then it makes sense now for btrfs_alloc_path(). But I still believe this looks like a bug in gfpflags_allow_blocking()... Thanks, Qu