Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp317962imu; Tue, 27 Nov 2018 12:55:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/U8Glepo5ZQ8Jfv/9ATiZqBkh2TlIhBVfe8XgnY66KKOMpnmvqk33nlsHFLfh1/NNOLM6Zh X-Received: by 2002:a63:df13:: with SMTP id u19mr30829758pgg.294.1543352155129; Tue, 27 Nov 2018 12:55:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543352155; cv=none; d=google.com; s=arc-20160816; b=qElPW7XaT08pMQrlaRlHQ0BcqRbSesFfqjNn6GS+Ccg8rXDyBqEbC25lVQSnQD8H6Z CHnHFHbpBXzzgs+GilJEhzab+/uyf2yqfw52nn5gbJhNl240k1pRUuGUxxmGT6dh3fh+ yVd70jbnm+FM8opiB2GU/TgKRGtbdbpHmN4AQ+/hHe5+wS4MkKMbCbPNSSEKvqTo2HT4 e9mxVTLXIfM3C/1BBAcRCpNr7e63uZdwEe+9+rUlVx0u5k/mUBTeyDYk3zgKUIzr8vwB H0+Y2e51sDDggRna6c1ws/59AQFw/h23Pk0vGq+UHEDQQS2NX5WBAY+ORccPUET8PMwb madA== 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=bqyE1nmXeAtPZbB2AL1Q4bwPXAN2rTBpblfeBKlhVg4=; b=G1VYAfphQiJiFUBbdcy2nvXuWaXFuQdRc5BWHFrZvtbyb+A7LYbP7rBOrD8xjE2IHA xHSCI6p1BEglBJyPhvFCrjqe5q6U+OGAAyj43oCrws7Ra0harMzxqxotEnEWlc3qR3Tt p8S5/G0yKurgrS/6nlNoQINwbcdkZRs+Zih96j1nspxRnwBx3UQc4qMim+fZrLtmfJ9v mwiu1it6iUMV/oHUoXQLPxvki7SGibFga1i8V1dt6bN1niuE/De9K9ytKB7MPwFUm5vo GdusG1XvwgLJYSjFYjaBXFmeF2GGXzN86ZSgAXRaVF+KhoCNNK9hUM/+d1pcBreenwoW d/1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=KgSSMt4L; 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 h19si4719149pgb.231.2018.11.27.12.55.24; Tue, 27 Nov 2018 12:55:55 -0800 (PST) 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=pass header.i=@toxicpanda-com.20150623.gappssmtp.com header.s=20150623 header.b=KgSSMt4L; 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 S1726580AbeK1Hxk (ORCPT + 99 others); Wed, 28 Nov 2018 02:53:40 -0500 Received: from mail-yw1-f65.google.com ([209.85.161.65]:45791 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbeK1Hxk (ORCPT ); Wed, 28 Nov 2018 02:53:40 -0500 Received: by mail-yw1-f65.google.com with SMTP id d190so9737973ywd.12 for ; Tue, 27 Nov 2018 12:54:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=toxicpanda-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=bqyE1nmXeAtPZbB2AL1Q4bwPXAN2rTBpblfeBKlhVg4=; b=KgSSMt4L+4tqXR2s+UHTYAZflYlIuedUbXzViNuZYxBCrGfB2P6tWYKhhL9LqkWnIY uIWLGg625SPIus4yfa8vQ4Rn0berTLnGHGJa0iC2cJa1eD73Mt8pBBGxNhs12Ms1ggKI uksj6n+fKLc9mFWtfr5/rf0CwViWF9qHyxCrZ5RORsfJAT+ehnebXCrGtBK2naK75PTa ZR/Etd+hEl93Th/ytTmMiCidhAapEKabckiaf41BfTMzQlwxwJd5YIaSy8qZoovKLOD6 z3SMMTiPewSfzgbh5hyY0w6FVDCe/+tBO5ZYPm47xWSCJszcmh28uTamHa22akWBpx2D BYuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=bqyE1nmXeAtPZbB2AL1Q4bwPXAN2rTBpblfeBKlhVg4=; b=mZLvC8a3JmbjzVN4ouw1BfR22aajXKsawcbZw4xPlUmXufaL5b6Njt6gqnyLxedXZC MP/3HpJDqkHDC08gEdncz6jxO+YTowKgUzOZlqqZxuqxxQ15eFziVCOLVfMl5rvaN+42 Z2QZiPBe3MZHnFxVWEQhxf1yAyxR/PMLppWhdULBkb5If6PhVxijPvdTPOrIzIvGCKK8 gK+G8b5TJePu9j/M7qMOM6UvFOnXC/+aWFZC52Nydqu9Qh1aaYyEX40Y4Kt1trZ6g05k ry+ImLOJeBJkOyszznavafsfikkeV5XphAKvwpl8fWbldVmOanAZBU0wv+TI6PvrrsC+ asAQ== X-Gm-Message-State: AA+aEWZFdU1eRndsAvuTKR2OX7UCd56g3UnC6eJ6ERpBMF50sQmBI5k1 u1ua/QqtnQ2YCCr3RyiiP1NLhg== X-Received: by 2002:a81:3883:: with SMTP id f125mr8960690ywa.507.1543352071016; Tue, 27 Nov 2018 12:54:31 -0800 (PST) Received: from localhost ([2620:10d:c091:180::1:4c40]) by smtp.gmail.com with ESMTPSA id r20sm5290513ywa.13.2018.11.27.12.54.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 27 Nov 2018 12:54:30 -0800 (PST) Date: Tue, 27 Nov 2018 15:54:29 -0500 From: Josef Bacik To: Dennis Zhou Cc: Jens Axboe , Tejun Heo , 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/13] blkcg: fix ref count issue with bio_blkcg() using task_css Message-ID: <20181127205427.v2x7ezd6jgkxg562@macbook-pro-91.dhcp.thefacebook.com> References: <20181126211946.77067-1-dennis@kernel.org> <20181126211946.77067-2-dennis@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181126211946.77067-2-dennis@kernel.org> User-Agent: NeoMutt/20180716 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 26, 2018 at 04:19:34PM -0500, Dennis Zhou wrote: > The bio_blkcg() function turns out to be inconsistent and consequently > dangerous to use. The first part returns a blkcg where a reference is > owned by the bio meaning it does not need to be rcu protected. However, > the third case, the last line, is problematic: > > return css_to_blkcg(task_css(current, io_cgrp_id)); > > This can race against task migration and the cgroup dying. It is also > semantically different as it must be called rcu protected and is > susceptible to failure when trying to get a reference to it. > > 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(). In blk-iolatency, association is > moved above the bio_blkcg() call to ensure it will not return %NULL. > > BFQ uses the old bio_blkcg() function, but I do not want to address it > in this series due to the complexity. I have created a private version > documenting the inconsistency and noting not to use it. > > Signed-off-by: Dennis Zhou > Acked-by: Tejun Heo Reviewed-by: Josef Bacik Thanks, Josef