Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2040642imm; Fri, 7 Sep 2018 09:54:19 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYU0Za2d8J1R6e6kEoRwK1RhAzpavlaQYIWUwObOrWsM2au6Y7bz2IaYbaGMbVVTzrLPbZt X-Received: by 2002:a62:c008:: with SMTP id x8-v6mr9504047pff.149.1536339259485; Fri, 07 Sep 2018 09:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536339259; cv=none; d=google.com; s=arc-20160816; b=mEaOwVnD1AIB+JYt9nNAFkntZJb6mpCjCd/nH/tcLFzIH+njLQF4y4lXBgsQg7rwHP cnJ8K8nvzOZ8TaU68aQ6unFaREDKfSflP+x31TrNCkBlXbCCGpFhesR8OeyDLCEZyIsU 7kdqclsAcNRpl/mYHJ4qM31XcdEsLm1IEbN8w0q7h+SYExOyoBBM99EkrBPavxYof8Xi sHcRUMrqi2+wgIOsS7E+HGnHLAwztoCMLLk1Dx149jRzodp6vglfSCqrv+wDbNg9C+wY U/Q3Nb/5nGM5FD9NH2mc48ZH/jQHHQLcg0pyMZWIEAc9gwVTy6Vwr9E9B80IQNa5hSGz quKw== 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; bh=AYh0rsaO0mmz5DzqRm/SBc9j8B8bdzOEyVdu2zac50c=; b=vUxnZFpqdyHeH0ZtG2jGvfqHD6ZejLHltAcqw0jVlk90pP0XVTMnM6Lnkw87EKqZBf E7yuLVBZf9gr1GbVphreaSqGmCMm9pXSBDdNjfGKIUQLriyOqgHh6HaF0tzPPLDPAj1S IiEBA7Kw8Ovb+zpAPjdSJECqVmBNJSasCe3bg7eBn/uy877ST0HrVf62PXc8XTosemA9 NaaKnlwq8F6tuuXK26Ejnl9EedpfQ66PkSzcXO6bI4JZPBbCDeZBZsyLMwJz8urfNf/b qY/LQ3nqGQe+66unVcNyNJ1dr+MXXh4TKIjbd8J3Q6MgD/uvwyxSt++er5IFtI1c/CdO Baxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=qdtROdG6; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t3-v6si8639273plj.413.2018.09.07.09.54.04; Fri, 07 Sep 2018 09:54:19 -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=qdtROdG6; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726735AbeIGVdz (ORCPT + 99 others); Fri, 7 Sep 2018 17:33:55 -0400 Received: from mail-yb1-f194.google.com ([209.85.219.194]:35094 "EHLO mail-yb1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726284AbeIGVdy (ORCPT ); Fri, 7 Sep 2018 17:33:54 -0400 Received: by mail-yb1-f194.google.com with SMTP id o17-v6so5694413yba.2; Fri, 07 Sep 2018 09:52:07 -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=AYh0rsaO0mmz5DzqRm/SBc9j8B8bdzOEyVdu2zac50c=; b=qdtROdG6MlI2jCeC8xPFJSCUsMb7JD7bxiKFKFDmA/o2LEJVqp737ya+RlQoKKsJvp lz0s8SDgxQptPm1+xTE3ZO2Bba1zBpbyvi0qepNCWwTC6H1EO/bLWIZE7YWTLPa+l4sy K1waJ9082Ka+RN68p0kVmJ2Y6Inb80QDcs3PbgMK+dV5zJY2hxzxGwsa2Xdj5yjLru7a sC/ZwVAqywy3UIgQuGcPxbEO57VuTG8keXI9n6clbrcWSFlvZkS+tkXBDJFg+QxiIU1S 2xymJ7ATjJzGENiDHS68iDIsmDDkgTvoTBwAHX3KbnUyzGY2Wt5qx+jSUMNHh/0+4tje GxVg== 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=AYh0rsaO0mmz5DzqRm/SBc9j8B8bdzOEyVdu2zac50c=; b=bUU7hHCOgOXB7kj2rR3ho2Zfvc8a1dFYCtJ4FMbHoTjNUHUo88HJ3XlOpzMfH3e+7c 5emed4HzdJCMMUyTLDj9T1/Bzg+Ary+oI48t8Kf8bqWlHgnCL2qtTp6JH2fv4LhRf3Wu snDK7Fm0qUXbSK0+m5lhsRrY5G77KaFwnuNCC3wpRPkjL2ZDO1c9o4B+WyOlmZw3n8/Q B5oNdAOgH9sLUo/zhPAQN/PCmTfjwyR81lB/LO4UAeApBcxpwuw7dCZqQYNyncVjKWza h86qBL5KwADsxW7HI/CmoxHe/3ftgKj8qJT1wY/U1deACnVPJXm3MF4xTrNDUVx+UO5u 2h2A== X-Gm-Message-State: APzg51Aa7w0pTSIkk19tJdVAPFzcMBNq7Cx5AhQrVbCwRW3152BIOZbm wIDYz1li5JsFtBVGhYXYcKg= X-Received: by 2002:a25:1fc1:: with SMTP id f184-v6mr4415450ybf.164.1536339127116; Fri, 07 Sep 2018 09:52:07 -0700 (PDT) Received: from localhost ([2620:10d:c091:180::1:70a9]) by smtp.gmail.com with ESMTPSA id x131-v6sm2864348ywd.81.2018.09.07.09.52.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Sep 2018 09:52:06 -0700 (PDT) Date: Fri, 7 Sep 2018 09:52:03 -0700 From: Tejun Heo To: Dennis Zhou Cc: Jens Axboe , Johannes Weiner , Josef Bacik , kernel-team@fb.com, linux-block@vger.kernel.org, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 01/12] blkcg: fix ref count issue with bio_blkcg using task_css Message-ID: <20180907165203.GA1100574@devbig004.ftw2.facebook.com> References: <20180906211045.29055-1-dennisszhou@gmail.com> <20180906211045.29055-2-dennisszhou@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180906211045.29055-2-dennisszhou@gmail.com> 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 On Thu, Sep 06, 2018 at 05:10:34PM -0400, Dennis Zhou wrote: > From: "Dennis Zhou (Facebook)" > > The accessor function bio_blkcg either returns the blkcg associated with > the bio or finds one in the current context. This can cause an issue > when trying to associate a bio with a blkcg. Particularly, it's the > third case that is problematic: > > return css_to_blkcg(task_css(current, io_cgrp_id)); > > As the above may race against task migration and the cgroup exiting, it > is not always ok to take a reference on the blkcg returned from > bio_blkcg. > > This patch adds association ahead of calling bio_blkcg rather than > after. This makes association a required and explicit step along the > code paths for calling bio_blkcg. blk_get_rl is modified as well to get > a reference to the blkcg it may use and blk_put_rl will always put the > reference back. Association is also moved above the bio_blkcg call to > ensure it will not return NULL in blk-iolatency. > > BFQ and CFQ utilize this flaw, but due to the complexity, I do not want > to address this in this series. I've created a private version of the > function with notes not to use it describing the flaw. Hopefully soon, > that code can be cleaned up. > > Signed-off-by: Dennis Zhou Acked-by: Tejun Heo -- tejun