Received: by 10.192.165.156 with SMTP id m28csp968813imm; Wed, 11 Apr 2018 10:04:01 -0700 (PDT) X-Google-Smtp-Source: AIpwx49FgunUXHBGycNG7Z3c0gPn8h/XhGZn4hgmUSz0dz+9CZlZeP6ckyi3KAfal6gWmRyPkOjc X-Received: by 10.99.42.209 with SMTP id q200mr3956142pgq.379.1523466241165; Wed, 11 Apr 2018 10:04:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523466241; cv=none; d=google.com; s=arc-20160816; b=FpQ6LvrBHTUIpcPXSQnF4hlOM6aQmlGds7Pj8KcdSO0PkcdSxgr5YDqB0eUUsL1sdX qV7I22H+zzilwgkBVkiZ0r/EMd4Sb22zmPadbY83Li8tza+Ko2t9nEKzJFj3uzTKR4qE 2C9vaZ7wueOb9exccLQNiV81oUpDbYc8s2JuGyMvIila0YBhc+2rVVLxszHvmATcq7I4 pNpscSXsPO5rz8Mjt4kosQobEi1S8AfinwrDA87kahxOIAdh7P6KbASMJAqW/XEz0p7d bls1cCjGPLsONde+muugpoNnN0VQWwjhYu+6crx4BGhOA7eV4hvdEmqOx+5txtd718lt SpOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=GYym7hPTZ11Ql9fg7AFi5M/NcNDqGI6PSRyDRQzJioM=; b=APriIKBu1OdaTAlg9O5ZhN2tfVPZul9NYBmRj92RXd+BvLI5lEsInR9AnKnQkhtvjv maLlmxHfaASyOeX9/sHGW+wFdueKmcU60WeLnDYv5oXTe4f+f3mgWrZAyne3Gwp+EDFk j4t1uAx4Ry9vJZZY+7Ru8utoG8UJIPp6TRuVWkuwx999616JByQ+euOJ1gY3EogkxlDb U6WwsR/Dv/3oC7IA750HqFIOi1ylXmgUerF8a2pSPwYaOzvV3LnwJVzeK/aYr1vP6/rZ PLi6L3medkKWVxuB3uZp8LGvWQIFdTUavAlaF9Xd6oGka3knQp997f8xZtP+AM+rBHC5 7iRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=enTb34EZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d21-v6si1502879plr.352.2018.04.11.10.03.21; Wed, 11 Apr 2018 10:04:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=enTb34EZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753040AbeDKRAY (ORCPT + 99 others); Wed, 11 Apr 2018 13:00:24 -0400 Received: from mail-yb0-f175.google.com ([209.85.213.175]:37497 "EHLO mail-yb0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751491AbeDKRAV (ORCPT ); Wed, 11 Apr 2018 13:00:21 -0400 Received: by mail-yb0-f175.google.com with SMTP id i13-v6so856014ybl.4; Wed, 11 Apr 2018 10:00:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=GYym7hPTZ11Ql9fg7AFi5M/NcNDqGI6PSRyDRQzJioM=; b=enTb34EZminkZNq3fat2nRJWrOq4KVFOkY4f4aOrdUn1YGF72BFSdVqd8mbt8Ttx2R VtWhu+fZMv3msnnm/uMJeMgWYWOUcz8OxBYIMwu9XQdOnLqW2PB48fQ35T1SDbaOWnPE zzKJ0niaqGIHQsKzHK+tF5Yr72bjR7zuvR962qM2U163UVhaHb0sKF13hGOOYcQsrgl8 8MozOvXeT5H2Aux+e83Fcb+bja8JgXinHNwYjJSz9VQ3KwJVU1VBGpJgeMZGeaoadArD gQbJjuAqDmrnFiHEDcKw9EjfLgZnwjshwKurlJQnKzLrAXcX8bbuQkaMB/IYKpwiHH0k 7rSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=GYym7hPTZ11Ql9fg7AFi5M/NcNDqGI6PSRyDRQzJioM=; b=KLWpL1LHFay84q7jad7gw0jEtxZJacEEiuUIXlBeQup2S8B0yxrvuEbo1WrTRRoCoe u3JrqpvpV6TCcQ5F/3M+rEXDZod68Xp0PhjQk6hjF7zgC/kNXksDpxycRv7N/JVpdWi+ pEVERMWCXWoiX5Bu+qeCJ/nDH2hrudvPjgEWrGSjLhHAPU5EoE0/VKB7fKkq93rTJy5h icMZw8jUbl6jHJL3KbSt/Boxxr//nVQIXD3zhHQ2LpKMn3KkXaOxZR9EI6vnHVVhp3rx TmAshkSlWnAfglFTISb+IJiJnJHcK5GYbJ6UJd35HmFy0fWJxA+9mTkHQyXnFQfzukkX 2JuA== X-Gm-Message-State: ALQs6tB5TO4kp6fJMxBDcDFkSFtO7Ccw0FWroqCzc7iZQ+Tri48h/tzl UzDJH+0n3i8/pcxpCtp56JM= X-Received: by 2002:a25:6089:: with SMTP id u131-v6mr2618713ybb.263.1523466020931; Wed, 11 Apr 2018 10:00:20 -0700 (PDT) Received: from localhost ([2620:10d:c091:200::1:e6ed]) by smtp.gmail.com with ESMTPSA id x84sm581143ywd.89.2018.04.11.10.00.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 11 Apr 2018 10:00:19 -0700 (PDT) Date: Wed, 11 Apr 2018 10:00:18 -0700 From: "tj@kernel.org" To: Bart Van Assche Cc: "00moses.alexander00@gmail.com" <00moses.alexander00@gmail.com>, "joseph.qi@linux.alibaba.com" , "nborisov@suse.com" , "linux-kernel@vger.kernel.org" , "linux-block@vger.kernel.org" , "gregkh@linuxfoundation.org" , "arnd@arndb.de" , "axboe@kernel.dk" , "shli@fb.com" Subject: Re: [PATCH v2] blk-cgroup: remove entries in blkg_tree before queue release Message-ID: <20180411170018.GL793541@devbig577.frc2.facebook.com> References: <20180407102148.GA9729@gmail.com> <20180409220938.GI3126663@devbig577.frc2.facebook.com> <20180411101242.GA2322@gmail.com> <20180411142019.GG793541@devbig577.frc2.facebook.com> <20180411142859.GB2322@gmail.com> <20180411144616.GI793541@devbig577.frc2.facebook.com> <20180411145123.GJ793541@devbig577.frc2.facebook.com> <20180411145632.GK793541@devbig577.frc2.facebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello, On Wed, Apr 11, 2018 at 04:42:55PM +0000, Bart Van Assche wrote: > On Wed, 2018-04-11 at 07:56 -0700, Tejun Heo wrote: > > And looking at the change, it looks like the right thing we should > > have done is caching @lock on the print_blkg side and when switching > > locks make sure both locks are held. IOW, do the following in > > blk_cleanup_queue() > > > > spin_lock_irq(lock); > > if (q->queue_lock != &q->__queue_lock) { > > spin_lock(&q->__queue_lock); > > q->queue_lock = &q->__queue_lock; > > spin_unlock(&q->__queue_lock); > > } > > spin_unlock_irq(lock); > > > > Otherwise, there can be two lock holders thinking they have exclusive > > access to the request_queue. > > I think that's a bad idea. A block driver is allowed to destroy the > spinlock it associated with the request queue as soon as blk_cleanup_queue() > has finished. If the block cgroup controller would cache a pointer to the > block driver spinlock then that could cause the cgroup code to attempt to > lock a spinlock after it has been destroyed. I don't think we need that kind > of race conditions. I see, but that problem is there with or without caching as long as we have queu_lock usage which reach beyond cleanup_queue, right? Whether that user caches the lock for matching unlocking or not doesn't really change the situation. Short of adding protection around queue_lock switching, I can't think of a solution tho. Probably the right thing to do is adding queue lock/unlock helpers which are safe to use beyond cleanup_queue. Thanks. -- tejun