Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp6295106rwb; Mon, 14 Nov 2022 17:59:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf6CK/tk0RcKl9Xik4L0yT5ecLeIOWQLwFp+9b+SGYQhTMSx78D2OrQ+VBsYoYFu4QmM85MK X-Received: by 2002:a63:3117:0:b0:462:644c:87ff with SMTP id x23-20020a633117000000b00462644c87ffmr13932093pgx.552.1668477540082; Mon, 14 Nov 2022 17:59:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668477539; cv=none; d=google.com; s=arc-20160816; b=dWzZHEEEzVRQ3BAYXdHirEMhdKpcKtRok42r/2x5d6lQEgVRERD2N7DO6gIl8yNGaE Rj3UggHXaNApZoMfq5W7WZFS18s/sHaayX77j+fUXRr6DmcfLqcTU1nEqwRu7hzot2UP d18ySmv6984bCGAm6tdPF1vAOj307PDwy49YUc0eFcFFOqYaN4yU8wcOsu84ViaB2Yqa i67qtZmQdwY/XZrTKcpayhNwD8ONJQEg2gjXH1zI2/fLWjeXFaTTH7aTu0GtlFwgNQtQ ra2Q4LvAIJ3jK/hZEZltS+i74Xpy1SGfwIYMeP+4WhgU9GhpRIkAOjTx6DsO/qbJGPV3 2cxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=VoYOc6QKU7PbHsQ/1cL6oT/RTMINrlQwRMv97mIwtyk=; b=YGg6GuqsYkg9IURPuPsRRt3XvtoFNNUKQfkR9EAEOeGoLk58C0uQ6/sVFEq5l+nsDJ FWe/LuiMwtnz2LxPHc8RX53cs2i6XsOA8jCFI9L6wYDb/tfSdUs0NgqblyYlA17ANe91 2yn6ZXaZoH7o9aO9MIFFIt0dD4CsKL5HcFmownhnmY575HAox097oW4QIJzjf8nOc3qf gnaix2w8FxsKEpK7E9/MMoMnPr4XBji+ynE+BBcXiidhaK1n8z+Y/wTkV04LDfLtubtl V5KEKvzP27kwzYY1wKjcod8pqA8+X4DsQu11hj1xAAiIC3zPSe3ivKRoNXPyBbSqHjuR Gy7w== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id s11-20020a170902c64b00b00186f22a06bdsi9356830pls.459.2022.11.14.17.58.45; Mon, 14 Nov 2022 17:58:58 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229774AbiKOBRE (ORCPT + 88 others); Mon, 14 Nov 2022 20:17:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231425AbiKOBRA (ORCPT ); Mon, 14 Nov 2022 20:17:00 -0500 Received: from dggsgout11.his.huawei.com (dggsgout11.his.huawei.com [45.249.212.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 932A512ADC; Mon, 14 Nov 2022 17:16:57 -0800 (PST) Received: from mail02.huawei.com (unknown [172.30.67.153]) by dggsgout11.his.huawei.com (SkyGuard) with ESMTP id 4NB7Yv3Jjlz4f3m6v; Tue, 15 Nov 2022 09:16:51 +0800 (CST) Received: from [10.174.176.73] (unknown [10.174.176.73]) by APP4 (Coremail) with SMTP id gCh0CgC329iE6HJjpFosAg--.10568S3; Tue, 15 Nov 2022 09:16:54 +0800 (CST) Subject: Re: [PATCH v2 4/5] blk-iocost: fix sleeping in atomic context warnning To: Tejun Heo , Yu Kuai Cc: hch@lst.de, josef@toxicpanda.com, axboe@kernel.dk, cgroups@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, yi.zhang@huawei.com, "yukuai (C)" References: <20221104023938.2346986-1-yukuai1@huaweicloud.com> <20221104023938.2346986-5-yukuai1@huaweicloud.com> From: Yu Kuai Message-ID: <1644d8fd-a0b4-a6fd-63a2-6309db1bfa11@huaweicloud.com> Date: Tue, 15 Nov 2022 09:16:52 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=gbk; format=flowed Content-Transfer-Encoding: 8bit X-CM-TRANSID: gCh0CgC329iE6HJjpFosAg--.10568S3 X-Coremail-Antispam: 1UD129KBjvJXoW7KF13ur48JFWrCry3uw1kGrg_yoW8WrWrpF yag3Wqyw4jqFnF9wsFyw1SvF1Skw109w4rA3s7Gasayr9rWrn3KFn5trWF9r10vry3XrWj vF4FqrW5Zr1UA3DanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDU0xBIdaVrnRJUUU9Y14x267AKxVW8JVW5JwAFc2x0x2IEx4CE42xK8VAvwI8IcIk0 rVWrJVCq3wAFIxvE14AKwVWUJVWUGwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xGY2AK02 1l84ACjcxK6xIIjxv20xvE14v26w1j6s0DM28EF7xvwVC0I7IYx2IY6xkF7I0E14v26r4U JVWxJr1l84ACjcxK6I8E87Iv67AKxVW0oVCq3wA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_Gc CE3s1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E 2Ix0cI8IcVAFwI0_Jr0_Jr4lYx0Ex4A2jsIE14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJV W8JwACjcxG0xvEwIxGrwACjI8F5VA0II8E6IAqYI8I648v4I1lFIxGxcIEc7CjxVA2Y2ka 0xkIwI1lc7I2V7IY0VAS07AlzVAYIcxG8wCF04k20xvY0x0EwIxGrwCFx2IqxVCFs4IE7x kEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E7480Y4vE14v26r106r1rMI8E 67AF67kF1VAFwI0_Jw0_GFylIxkGc2Ij64vIr41lIxAIcVC0I7IYx2IY67AKxVWUJVWUCw CI42IY6xIIjxv20xvEc7CjxVAFwI0_Jr0_Gr1lIxAIcVCF04k26cxKx2IYs7xG6rW3Jr0E 3s1lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x0267AKxVWUJVW8JbIYCT nIWIevJa73UjIFyTuYvjfUoOJ5UUUUU X-CM-SenderInfo: 51xn3trlr6x35dzhxuhorxvhhfrp/ X-CFilter-Loop: Reflected X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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 Hi, ?? 2022/11/15 6:07, Tejun Heo ะด??: > On Fri, Nov 04, 2022 at 10:39:37AM +0800, Yu Kuai wrote: >> From: Yu Kuai >> >> match_u64() is called inside ioc->lock, which causes smatch static >> checker warnings: >> >> block/blk-iocost.c:3211 ioc_qos_write() warn: sleeping in atomic context >> block/blk-iocost.c:3240 ioc_qos_write() warn: sleeping in atomic context >> block/blk-iocost.c:3407 ioc_cost_model_write() warn: sleeping in atomic >> context >> >> Fix the problem by introducing a mutex and using it while prasing input >> params. > > It bothers me that parsing an u64 string requires a GFP_KERNEL memory > allocation. > >> @@ -2801,9 +2806,11 @@ static void ioc_rqos_queue_depth_changed(struct rq_qos *rqos) >> { >> struct ioc *ioc = rqos_to_ioc(rqos); >> >> + mutex_lock(&ioc->params_mutex); >> spin_lock_irq(&ioc->lock); >> ioc_refresh_params(ioc, false); >> spin_unlock_irq(&ioc->lock); >> + mutex_unlock(&ioc->params_mutex); >> } > > Aren't the params still protected by ioc->lock? Why do we need to grab both? Yes, the params is updated inside ioc->lock, but they can be read without the lock before updating them, which is protected by mutex instead. > > Any chance I can persuade you into updating match_NUMBER() helpers to not > use match_strdup()? They can easily disable irq/preemption and use percpu > buffers and we won't need most of this patchset. Do you mean preallocated percpu buffer? Is there any example I can learn? Anyway, replace match_strdup() to avoid memory allocation sounds good. Thanks, Kuai > > Thanks. >