Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp10952916imu; Thu, 6 Dec 2018 09:12:48 -0800 (PST) X-Google-Smtp-Source: AFSGD/WfuOoXssTwZHO5XZ3bzdP0chp/A/6Sxn+nVm3Pedkfz0RqYtkuqSqs2bGyviZpzsJ8Ybcx X-Received: by 2002:a63:3546:: with SMTP id c67mr25226825pga.284.1544116368297; Thu, 06 Dec 2018 09:12:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544116368; cv=none; d=google.com; s=arc-20160816; b=jq1mvHdsiyh7GUj3rJNlSOZ18sDCilX63bI+NJSAuzt9tEY5+iLCnVYFwInUfvgmEt 2sl5vZhoD4ZM4OlQ5Zm7Rw0fTCoNXWXAsV98nAhcyI6nIMWtFPMIgaARtyMH7u4jyJV2 OjuMn8oItH/c/i2npu9MWVIoD+8oBMegx5cq70lL6J09kWa1ncRpsHpPeJC5PCNmxips Pn8t9YchXdixZylexScm64UWxnVH6SIJ/DUgWRHnKNH8dFFEm0yIk0A8wjwTMkCtjlh3 RotJDYbd0JscWDKRWTSXakCGby/KBbEHG+4A6HNEVGysJMrjvcI1gnmLvjNs4tAb76Ij Q/bQ== 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=kk4RbzqHHzQDb9vXoUHlKfqVsZCOyY4+FfrWgQJsLBc=; b=Y4zq2NZfY5Xy4uAzUfTK8AhZ/P1Zds1jM41JNH7D3wCtkskYcaDq+ERics/WPSLzQr L0nrpR8XHq6BOdYJwAvnY2MFea9tAxVkPVES807t90g7ohh+wtaBdzow8eu2et2D/dyE U67ojzxI3b/JfyE4gapCslM2iQkYjp7dkjW/JlKFwZHp/YlzTv5qKV/jgtaa3DrJ9ryS IaLKzMXc9Xomcxs1PwGxPcTQl7DcPqySmOlGFu9CJKXKMSSGeo+Pst/8pZTzLCkXNE1k q9+RSJOaeh/WmCd4NIvoYb3dSMLHpBkTLk/MkbvTgNuRiFIWCLYnKtFmz0Wc4yVKLszD voqw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=hT6tyLGz; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l194si647870pga.594.2018.12.06.09.12.25; Thu, 06 Dec 2018 09:12:48 -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=@gmail.com header.s=20161025 header.b=hT6tyLGz; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726061AbeLFRI2 (ORCPT + 99 others); Thu, 6 Dec 2018 12:08:28 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:33303 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725907AbeLFRI2 (ORCPT ); Thu, 6 Dec 2018 12:08:28 -0500 Received: by mail-pl1-f196.google.com with SMTP id z23so457605plo.0; Thu, 06 Dec 2018 09:08:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=kk4RbzqHHzQDb9vXoUHlKfqVsZCOyY4+FfrWgQJsLBc=; b=hT6tyLGzyhbVX8Ulu+o51Fb1IncgzS8ELhJ+UJ1CUbHWZ+WOo4XguGbP6vCJsn5xRq Lpuv30OOK1t4yxlbn0E664n4kwGki6XLl1oM8mz6M1H61aFoA8MTkN0a18hg8a+0pAIE zzhRcIbiLL2mIC+A3hw5SPiPtqN2Yzi+UOO6K2gTbZqm8aCHoD1F0Qh/kk8hjGJaQuj0 HD+WB3AQ6Z+h+uZstlmgHUV1560ZB4Dm1VRSG11lHdy/JA0rNavEdwSOvl6wDOEKCr7S 04GFBN8GKIGsjsH3iuM41CZ15eLZRDF+cuY4Sp4+DDDamGEZ8TrYyWRao5ACBRZ8zJQJ +KZQ== 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=kk4RbzqHHzQDb9vXoUHlKfqVsZCOyY4+FfrWgQJsLBc=; b=jWsECSwJKUgzXIhjLS6yNwN/BWIY85Snrav6c58J6/bUKrKl/k/AB79vHU9Jm/FQVb tAB0zNosfFlajSHVORFTyj6tD9VZBaNy2nVyHFO9LsYZ02Eq/Bkk0e+n0m6lI2DHRLz8 LqpVOLhhbj5UCqw01+TKnJGEqquC9GQcYOMmU6ckg0kR7MJs9O0X1ChsEldTZ2NPd6Ro 8TSOu6oaAKUeZkMEdi0uy7DcHP8G0R+NrgO+VxTIFMde9RL20rZbnq6a3Nn9bq1kkkak IzDgTr0ALl2NbZnt4csXv+lVdN7CIqOYav4TnS2yaXV1Li38398zD54CEtUunkDtsMc5 yCbQ== X-Gm-Message-State: AA+aEWbD0KZaOldBjRMHvcA1lXErkFA1+fwRv8WkOG4iGzOvizgHTMOd xpr60r6lidBWDUim/osWGdQ= X-Received: by 2002:a17:902:8484:: with SMTP id c4mr28204948plo.59.1544116106830; Thu, 06 Dec 2018 09:08:26 -0800 (PST) Received: from gmail.com (c-73-140-212-29.hsd1.wa.comcast.net. [73.140.212.29]) by smtp.gmail.com with ESMTPSA id y1-v6sm1271992pfb.81.2018.12.06.09.08.25 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 06 Dec 2018 09:08:25 -0800 (PST) Date: Thu, 6 Dec 2018 09:08:23 -0800 From: Andrei Vagin To: David Howells Cc: viro@zeniv.linux.org.uk, Greg Kroah-Hartman , Tejun Heo , Li Zefan , Johannes Weiner , cgroups@vger.kernel.org, fenghua.yu@intel.com, torvalds@linux-foundation.org, ebiederm@xmission.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, mszeredi@redhat.com Subject: Re: [PATCH 21/34] kernfs, sysfs, cgroup, intel_rdt: Support fs_context [ver #12] Message-ID: <20181206170822.GA15790@gmail.com> References: <153754740781.17872.7869536526927736855.stgit@warthog.procyon.org.uk> <153754758187.17872.2791003837321822804.stgit@warthog.procyon.org.uk> <20181119042340.GA31532@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=koi8-r Content-Disposition: inline In-Reply-To: <20181119042340.GA31532@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Nov 18, 2018 at 08:23:42PM -0800, Andrei Vagin wrote: > On Fri, Sep 21, 2018 at 05:33:01PM +0100, David Howells wrote: > > @@ -1993,57 +2009,53 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask, int ref_flags) > > return ret; > > } > > > > -struct dentry *cgroup_do_mount(struct file_system_type *fs_type, int flags, > > - struct cgroup_root *root, unsigned long magic, > > - struct cgroup_namespace *ns) > > +int cgroup_do_get_tree(struct fs_context *fc) > > { > > - struct dentry *dentry; > > - bool new_sb; > > + struct cgroup_fs_context *ctx = cgroup_fc2context(fc); > > + int ret; > > > > - dentry = kernfs_mount(fs_type, flags, root->kf_root, magic, &new_sb); > > + ctx->kfc.root = ctx->root->kf_root; > > + > > + ret = kernfs_get_tree(fc); > > + if (ret < 0) > > + goto out_cgrp; > > > > /* > > * In non-init cgroup namespace, instead of root cgroup's dentry, > > * we return the dentry corresponding to the cgroupns->root_cgrp. > > */ > > - if (!IS_ERR(dentry) && ns != &init_cgroup_ns) { > > + if (ctx->ns != &init_cgroup_ns) { > > struct dentry *nsdentry; > > struct cgroup *cgrp; > > > > mutex_lock(&cgroup_mutex); > > spin_lock_irq(&css_set_lock); > > > > - cgrp = cset_cgroup_from_root(ns->root_cset, root); > > + cgrp = cset_cgroup_from_root(ctx->ns->root_cset, ctx->root); > > > > spin_unlock_irq(&css_set_lock); > > mutex_unlock(&cgroup_mutex); > > > > - nsdentry = kernfs_node_dentry(cgrp->kn, dentry->d_sb); > > - dput(dentry); > > - dentry = nsdentry; > > + nsdentry = kernfs_node_dentry(cgrp->kn, fc->root->d_sb); > > + if (IS_ERR(nsdentry)) > > + return PTR_ERR(nsdentry); > > + dput(fc->root); > > + fc->root = nsdentry; > > } > > > > - if (IS_ERR(dentry) || !new_sb) > > - cgroup_put(&root->cgrp); > > I don't see where this cgroup_put() has been moved. David, have you looked at this problem? It isn't fixed in linux-next yet. https://travis-ci.org/avagin/linux/jobs/463960763 Thanks, Andrei > > With this patch, the next script works only once, on the second attempt > it hangs up on mounting a cgroup file system. > > This is the only suspicious place in this patch what I have found. > > [root@fc24 ~]# cat fs-vs-cg > d=$(mktemp -d /tmp/cg.XXXXXX) > mkdir $d/a > mkdir $d/b > mount -t cgroup -o none,name=xxxx xxx $d/a > mount -t cgroup -o none,name=xxxx xxx $d/b > umount $d/a > umount $d/b > > [root@fc24 ~]# unshare -m --propagation private bash -x fs-vs-cg > ++ mktemp -d /tmp/cg.XXXXXX > + d=/tmp/cg.yUfagS > + mkdir /tmp/cg.yUfagS/a > + mkdir /tmp/cg.yUfagS/b > + mount -t cgroup -o none,name=xxxx xxx /tmp/cg.yUfagS/a > + mount -t cgroup -o none,name=xxxx xxx /tmp/cg.yUfagS/b > + umount /tmp/cg.yUfagS/a > + umount /tmp/cg.yUfagS/b > [root@fc24 ~]# unshare -m --propagation private bash -x fs-vs-cg > ++ mktemp -d /tmp/cg.XXXXXX > + d=/tmp/cg.ippWUn > + mkdir /tmp/cg.ippWUn/a > + mkdir /tmp/cg.ippWUn/b > + mount -t cgroup -o none,name=xxxx xxx /tmp/cg.ippWUn/a > ^Z > [1]+ Stopped unshare -m --propagation private bash -x fs-vs-cg > > [root@fc24 ~]# ps > PID TTY TIME CMD > 556 pts/0 00:00:00 bash > 591 pts/0 00:00:00 bash > 595 pts/0 00:00:00 mount > 596 pts/0 00:00:00 ps > > [root@fc24 ~]# bg > [1]+ unshare -m --propagation private bash -x fs-vs-cg & > > [root@fc24 ~]# cat /proc/595/stack > [<0>] msleep+0x38/0x40 > [<0>] cgroup1_get_tree+0x4e1/0x72c > [<0>] vfs_get_tree+0x5e/0x140 > [<0>] do_mount+0x326/0xc70 > [<0>] ksys_mount+0xba/0xd0 > [<0>] __x64_sys_mount+0x21/0x30 > [<0>] do_syscall_64+0x60/0x210 > [<0>] entry_SYSCALL_64_after_hwframe+0x49/0xbe > [<0>] 0xffffffffffffffff >