Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp630104rwb; Wed, 16 Nov 2022 05:46:51 -0800 (PST) X-Google-Smtp-Source: AA0mqf4Xl2LveVWdXMjaaeVlWHBeW6UVnsxIi9CeModTzhfLLh5qai4BYwEhngIUvOr24OIbnbDx X-Received: by 2002:a05:6402:378c:b0:463:ab06:f338 with SMTP id et12-20020a056402378c00b00463ab06f338mr19188513edb.371.1668606410791; Wed, 16 Nov 2022 05:46:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668606410; cv=none; d=google.com; s=arc-20160816; b=DsL9U/Iu02ZCLhnBRzAORcnIIf5sFAtE/RLcZJc/yzd/+v/Lo0z4Aj/Z3wWx3Z83BZ 4UB7N8+M24oSMSeKPeGau23c7JlVeVX5bnrikdzledp9XfLNVcxkqz3aQYDxPjSqQ3Ay tOUgGm0PMFT9EWHjhRmcp/dmg/0p4Q5r3kkdp1VGFfM2a8UlNrAyen0KDCfCiZqR8Gz+ VGhjvmIWUkq370p/mVNI3khuBng+sD3DVbfvCSbN7cWK1UvSQubRohopRgWiP08SeCjW cnS333wX/2kgOdNrbx4YxPv6ge26IRo+bkhmfO9PuF+p4XP5sAbnMk3oSGYvqAPiTJT7 zV+Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:reply-to:message-id :subject:cc:to:from:date:dkim-signature:dkim-signature; bh=t364W5skI1j7pC0w2AvM+QLo/wdtr/H5Ea49+U8AtMc=; b=QMLDSoTI4u3GN+AytDFEgrAd6WkGK7y43HoPJZo2bqkIYnun5dk+cTewSNVwBL+gNj 8BCqctt/d+GAYfa053IEeQSSCFNcZAQs/8IXnubhu0/5noHA2vZXpSO3FxTXe7RGt0Zc Eai3Xd3MdCqW1L1AdFnjdSOOWMBEBv2a7gdSYla3V77Kh1phw242HFeYCmi/qLh6DRob zJ9MtJkldXNLcgitQbMl7YEqI5p4pvzFAgzRPO0IX8tKJSSoe2Trnh6CTiyE4p6LX8ij d1d6tCF+xTJZhKZojIp3FlDJt6aY+QoC5lye2p+Q175L/FOgclYd0QWTUrCZ+TLNNPu3 kJBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=VrJh+enc; dkim=neutral (no key) header.i=@suse.cz; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x5-20020a05640226c500b00461c252c3f8si14628763edd.382.2022.11.16.05.46.28; Wed, 16 Nov 2022 05:46:50 -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; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=VrJh+enc; dkim=neutral (no key) header.i=@suse.cz; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238895AbiKPM2d (ORCPT + 91 others); Wed, 16 Nov 2022 07:28:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46944 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232934AbiKPM2Q (ORCPT ); Wed, 16 Nov 2022 07:28:16 -0500 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4674B6464; Wed, 16 Nov 2022 04:25:08 -0800 (PST) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F171E1F917; Wed, 16 Nov 2022 12:25:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1668601506; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t364W5skI1j7pC0w2AvM+QLo/wdtr/H5Ea49+U8AtMc=; b=VrJh+encNcOBAIl3/cjFZK9Nocs0SXz/AOGoRvqvdmM1mWu1WK7/VOZszqpXeTNKWf2EsQ zNt3gJhvrgihspuRdUuBVkUUvpiY18odfvRJdL6prEVSLjlGDcNTKpIclBiOK9O0c6GHPR I+gcLso5Qbj2Eq90+rbRHXL4ZF4nM9s= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1668601506; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=t364W5skI1j7pC0w2AvM+QLo/wdtr/H5Ea49+U8AtMc=; b=bxHtpW1dOm4kIsRe4Tr0SSD09ophd578bUhdYwWBQIPIp6nVSbTG/DGqQsyTz4rmY7CUkV 1xzoOU46gtgs0mCA== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AF69213480; Wed, 16 Nov 2022 12:25:06 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id v5LxKaLWdGOiFgAAMHmgww (envelope-from ); Wed, 16 Nov 2022 12:25:06 +0000 Date: Wed, 16 Nov 2022 13:24:40 +0100 From: David Sterba To: Qu Wenruo 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 Subject: Re: [PATCH v4 1/3] btrfs: add might_sleep() to some places in update_qgroup_limit_item() Message-ID: <20221116122440.GN5824@suse.cz> Reply-To: dsterba@suse.cz 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3918175e-dddd-2a55-32c4-c07de78ff4cb@gmx.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_SOFTFAIL 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 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.