Received: by 2002:ad5:4acb:0:0:0:0:0 with SMTP id n11csp4162113imw; Tue, 19 Jul 2022 00:35:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1uPR7POOeV9jNzqUCnGqPKjbQ5soJfza8XMB7iHZ07hWnCpYQczcJUHobrmcDIjOR0HEtjJ X-Received: by 2002:a17:90b:4c05:b0:1ef:e637:2cf4 with SMTP id na5-20020a17090b4c0500b001efe6372cf4mr35941754pjb.42.1658216110451; Tue, 19 Jul 2022 00:35:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658216110; cv=none; d=google.com; s=arc-20160816; b=iNyabsBkTOvEetEa4SmrIQ67Pj4HcV8GNhPlLvsLJaKNL1sOQJWi7eRFNWkn4UcvvM Ax0yLQ7gzD7941vjI488fauDHKC0rZj8raMis5vizizy4YC7btKE3iwC9Q3TRXNmTDZf DTkVcuocMeeg58l7ANZAJ+9LNMR6BVkz9SWlHsy3irSU8wqgS0D+f7br6F6VUWBbwgK/ 3NMJQvzuaLljyclwk1YhgXkJYp7Q/X0Pdic6WafohJMkpRu/BDI40XmkxwpFqbxfw8F+ Cq+hX85YOyKYkcOC4N05M2/JFnnUZKnnbyhtyfH/CwQskCQSXAMo1UJqBqVf5jlmqwbm VqEg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=u5KxztmCmMVHIN310A4ZHMWsumpUd/uei+99VlIfECo=; b=bKVraLPM0jFZnXBJFkHyXyEW2nW7j0qVhbneWqbZfbpqfMKaMJMLKFEsG4CeluRV8V fvnRikhlvZG6Nw6S7wABel3BzF0f+zDp49+R27ga2H38tn6IwIPYsW8W36bJ7c1YRrci 6+bJlB1qnvW94+458orvoYf4H5Gjb0Owt1G3xM7sOflalhvoezXtPJo7cI6Eomx3iKic 6OpWatuWcM0V1Gi4vvPrCPGJ+Q0EkCONT75es3C4/+C2b3b+iVHC+GHEzD74fG8v3bwU a8fOEp0i9m+mPa9gKfXyjlNmBp4TzMvYhqea2z5bxeQkdILo327XZ2m9Bi64OfO12Y7a 2wbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=g45peOwJ; 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=bytedance.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mi1-20020a17090b4b4100b001ed4a56d81fsi4650985pjb.49.2022.07.19.00.34.53; Tue, 19 Jul 2022 00:35:10 -0700 (PDT) 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=@bytedance-com.20210112.gappssmtp.com header.s=20210112 header.b=g45peOwJ; 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=bytedance.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230329AbiGSGxt (ORCPT + 99 others); Tue, 19 Jul 2022 02:53:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230262AbiGSGxs (ORCPT ); Tue, 19 Jul 2022 02:53:48 -0400 Received: from mail-yw1-x112b.google.com (mail-yw1-x112b.google.com [IPv6:2607:f8b0:4864:20::112b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9021E2873F for ; Mon, 18 Jul 2022 23:53:47 -0700 (PDT) Received: by mail-yw1-x112b.google.com with SMTP id 00721157ae682-31e560aa854so18944537b3.6 for ; Mon, 18 Jul 2022 23:53:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=u5KxztmCmMVHIN310A4ZHMWsumpUd/uei+99VlIfECo=; b=g45peOwJLERlzIw9j9Qr3FglyHx1ejYM46zmBvA/t4aMhMusgrlHHP7DtNqT3w8UDx +nBrmbn3AeWkJLwpUK3lBY+pXw5XeerP0NGTxCjRBjj8iozdPjAL8Jci7xtIVoqKdBHL fEUljn0PqIWZr/hPjTugMvYwnqskDlL10SVhxZ8CnPVRvTIxBC5x8rAXgDmSAduRjwo4 vhYvaSwgrqv7mSpvQ5A7gKQbEfS+zIX/0XYSM/O/B+apqFIO+1NiJatid+NqnQIqIo7K L1w3wWiR2lvJZHwarcjfbBoMYr2KyA83S8A3w/tgFxGpzA8wF+Vuh0UAE5vn24mWyr64 ig1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=u5KxztmCmMVHIN310A4ZHMWsumpUd/uei+99VlIfECo=; b=p+n/JAUnrhRXhj/hpDvF5fyzjuQyCdG8AZcmivP3SqpmGRL3EN2Iddz/ckmZ3F4wU4 y5Rg47MsKbHcPDcMRMkdpK2e2MWh+ardWWgN17ZEVLtVArqLARSu4FRQCJ894H0fcr+h CRcDNUsmDb0US+kb0nSUkDE8Vj+7zy6ba0uJ6ScZdsRp4JFYeIIwO1dZyjvPk5FiPEMh c7VHjMwJ0nsB1ZrkSiioRBssDdjfdF78uayUGK/ZC97NQGHoBK8LtdwResk6n16fVBDw 9nUIdQJ3cAahmJYRF2/rxZToYJT3XrDd1JagDYA5V0z8LTrmb3zAhvVz18XELA/OcJZA U8CA== X-Gm-Message-State: AJIora+ko8zAIC6khWqM10eWYn8wGWjB9oAmIzbHpT0Fq72/6Tt+0JO0 6845Fz99EA0jhexPjO236pKRuctu+xI4Xo5l+WSfBQ== X-Received: by 2002:a0d:ca88:0:b0:31d:c7a:6ec3 with SMTP id m130-20020a0dca88000000b0031d0c7a6ec3mr35667468ywd.141.1658213626831; Mon, 18 Jul 2022 23:53:46 -0700 (PDT) MIME-Version: 1.0 References: <20220718083646.67601-1-hanjinke.666@bytedance.com> In-Reply-To: <20220718083646.67601-1-hanjinke.666@bytedance.com> From: Muchun Song Date: Tue, 19 Jul 2022 14:53:09 +0800 Message-ID: Subject: Re: [PATCH] block: don't allow the same type rq_qos add more than once To: Jinke Han Cc: Jens Axboe , Tejun Heo , "open list:BLOCK LAYER" , LKML , Cgroups Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_NONE,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 Mon, Jul 18, 2022 at 4:37 PM Jinke Han wrote: > > From: hanjinke > > In our test of iocost, we encounttered some list add/del corrutions of > inner_walk list in ioc_timer_fn. > The resean can be descripted as follow: > > cpu 0 cpu 1 > ioc_qos_write ioc_qos_write > > ioc = q_to_ioc(bdev_get_queue(bdev)); > if (!ioc) { > ioc = kzalloc(); ioc = q_to_ioc(bdev_get_queue(bdev)); > if (!ioc) { > ioc = kzalloc(); > ... > rq_qos_add(q, rqos); > } > ... > rq_qos_add(q, rqos); > ... > } > > When the io.cost.qos file is written by two cpu concurrently, rq_qos may > be added to one disk twice. In that case, there will be two iocs enabled > and running on one disk. They own different iocgs on their active list. > In the ioc_timer_fn function, because of the iocgs from two ioc have the > same root iocg, the root iocg's walk_list may be overwritten by each > other and this lead to list add/del corrutions in building or destorying > the inner_walk list. > > And so far, the blk-rq-qos framework works in case that one instance for > one type rq_qos per queue by default. This patch make this explicit and > also fix the crash above. > > Signed-off-by: hanjinke The change LGTM. Maybe it is better to add a Fixes tag here so that others can easily know what Linux versions should be backported. Reviewed-by: Muchun Song Thanks.