Received: by 10.223.164.202 with SMTP id h10csp660096wrb; Wed, 22 Nov 2017 13:13:35 -0800 (PST) X-Google-Smtp-Source: AGs4zMb//hUq6h4LXuvRocz8lArgdtxjPnz8otfhTANgRbHpwYCoMoYJXHhYlJslJrLu5EBq6YaC X-Received: by 10.98.34.79 with SMTP id i76mr20545524pfi.42.1511385215442; Wed, 22 Nov 2017 13:13:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511385215; cv=none; d=google.com; s=arc-20160816; b=KL3WDQ6tIn8v8+V1nKq/61iBvkvxUJ0qByJQia/EV8Wpe8fdI54d6VrnPNj3kxOVq6 Y+SzVjYGqM1UxmKNgDkppySHsgk+ssCvoA7kvBtvfkQ9cQLSrmuciB0j14VnwiQGukhh nEL43n5cYP5I4wZP3yGz89ChlIHq06WL6JVdYqyDsQgOqxDZIothBFa3PBwGGImyaBam 4HS/FRdfc426uiZZG9bXisV5cu5VrjIW+TgkSuGRsfyKwOv3lQFEFe1niQAn506Ys4Xn X8zwl5J7lo/8C7BRnBOYHey2F1xb5E/2CX3kUMB/o2C/6C3jV4HloDVX0nTe3dtclOZD FD1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=FGLJDp11rlDDJQIY8aKvaIFT0jTiz9+8dFm5SSQRyJo=; b=QyPeltI4DBcCtFGRVZiNlDh7HjqYHe6wtgEsxduJY3FE+mSBmDe5UqYYAfauYM9hZ3 r79sM0OZqzkbIj0tUzv4ZGgyx+hsvEbG/T0A6ah05zHKSgyz+azodGHMheAUeXbxraWt li1E4gvRyaVyra/BhEeUN+CEhMo1qzuxKe4A9tmEYr8Zaa0IKdJ6dtHMOKkEZ2ST0ftC Ll8RM/LBSC82OEVjxU0QevxMzfwyEjxyZ8PrwPCkVDWMb5PM7F9uo2buqrndBPTM2o3t fH7IqBfUx7atEdNgeG9JEt7Uw964hCmpL9yaOqpOjgknk7DSewZ4SWJcrIokMteEqIXv 2O+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TKjjPirA; 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 z15si14357405pgs.492.2017.11.22.13.13.24; Wed, 22 Nov 2017 13:13:35 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=TKjjPirA; 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 S1752222AbdKVVLj (ORCPT + 77 others); Wed, 22 Nov 2017 16:11:39 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:44496 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751751AbdKVVIU (ORCPT ); Wed, 22 Nov 2017 16:08:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=FGLJDp11rlDDJQIY8aKvaIFT0jTiz9+8dFm5SSQRyJo=; b=TKjjPirAHLjjvJvNcX6hYNYb/ MLIsU8x8G5tQzvKI7h6VzIZ2vusJcaWnikO9zLB2zUuDT/pGypoxfz22JyqiI/lfCpg/qeJrh7Hlt UhzWo4Wbm24Sej1UNNi8aBShE7ZSHlPksgyJSBhUit9jg9hRpPho1FN+14K5k+3v4G66/oYLXpDLH kP/ZNaFBne1bdztojOSrf+FWY8gX7TziHNgaGG+Lp7TpYW7cL3Y3vF47AAH53nxRDd06LWK8r+nHM X1b8TFYCXGEveZRvdG8jGDN4r3dIKZliiK1fJr2GniVNQvRZV7oxjKQD8EDdlWkwaMd6BcXbGlvuL JNuBXlkIw==; Received: from willy by bombadil.infradead.org with local (Exim 4.87 #1 (Red Hat Linux)) id 1eHcFn-0007xu-P4; Wed, 22 Nov 2017 21:08:19 +0000 From: Matthew Wilcox To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Cc: Matthew Wilcox Subject: [PATCH 50/62] cgroup: Remove IDR wrappers Date: Wed, 22 Nov 2017 13:07:27 -0800 Message-Id: <20171122210739.29916-51-willy@infradead.org> X-Mailer: git-send-email 2.9.5 In-Reply-To: <20171122210739.29916-1-willy@infradead.org> References: <20171122210739.29916-1-willy@infradead.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Matthew Wilcox The IDR now behaves the way the cgroup wrappers made the IDR behave, so the wrappers are no longer needed. Signed-off-by: Matthew Wilcox --- kernel/cgroup/cgroup.c | 59 ++++++++++---------------------------------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c index 351b355336d4..67b4c2aa69a9 100644 --- a/kernel/cgroup/cgroup.c +++ b/kernel/cgroup/cgroup.c @@ -80,12 +80,6 @@ EXPORT_SYMBOL_GPL(cgroup_mutex); EXPORT_SYMBOL_GPL(css_set_lock); #endif -/* - * Protects cgroup_idr and css_idr so that IDs can be released without - * grabbing cgroup_mutex. - */ -static DEFINE_SPINLOCK(cgroup_idr_lock); - /* * Protects cgroup_file->kn for !self csses. It synchronizes notifications * against file removal/re-creation across css hiding. @@ -291,37 +285,6 @@ bool cgroup_on_dfl(const struct cgroup *cgrp) return cgrp->root == &cgrp_dfl_root; } -/* IDR wrappers which synchronize using cgroup_idr_lock */ -static int cgroup_idr_alloc(struct idr *idr, void *ptr, int start, int end, - gfp_t gfp_mask) -{ - int ret; - - idr_preload(gfp_mask); - spin_lock_bh(&cgroup_idr_lock); - ret = idr_alloc(idr, ptr, start, end, gfp_mask & ~__GFP_DIRECT_RECLAIM); - spin_unlock_bh(&cgroup_idr_lock); - idr_preload_end(); - return ret; -} - -static void *cgroup_idr_replace(struct idr *idr, void *ptr, int id) -{ - void *ret; - - spin_lock_bh(&cgroup_idr_lock); - ret = idr_replace(idr, ptr, id); - spin_unlock_bh(&cgroup_idr_lock); - return ret; -} - -static void cgroup_idr_remove(struct idr *idr, int id) -{ - spin_lock_bh(&cgroup_idr_lock); - idr_remove(idr, id); - spin_unlock_bh(&cgroup_idr_lock); -} - static bool cgroup_has_tasks(struct cgroup *cgrp) { return cgrp->nr_populated_csets; @@ -1883,7 +1846,7 @@ int cgroup_setup_root(struct cgroup_root *root, u16 ss_mask, int ref_flags) lockdep_assert_held(&cgroup_mutex); - ret = cgroup_idr_alloc(&root->cgroup_idr, root_cgrp, 1, 2, GFP_KERNEL); + ret = idr_alloc(&root->cgroup_idr, root_cgrp, 1, 2, GFP_KERNEL); if (ret < 0) goto out; root_cgrp->id = ret; @@ -4532,7 +4495,7 @@ static void css_free_work_fn(struct work_struct *work) int id = css->id; ss->css_free(css); - cgroup_idr_remove(&ss->css_idr, id); + idr_remove(&ss->css_idr, id); cgroup_put(cgrp); if (parent) @@ -4589,7 +4552,7 @@ static void css_release_work_fn(struct work_struct *work) if (ss) { /* css release path */ - cgroup_idr_replace(&ss->css_idr, NULL, css->id); + idr_replace(&ss->css_idr, NULL, css->id); if (ss->css_released) ss->css_released(css); } else { @@ -4605,7 +4568,7 @@ static void css_release_work_fn(struct work_struct *work) tcgrp = cgroup_parent(tcgrp)) tcgrp->nr_dying_descendants--; - cgroup_idr_remove(&cgrp->root->cgroup_idr, cgrp->id); + idr_remove(&cgrp->root->cgroup_idr, cgrp->id); cgrp->id = -1; /* @@ -4731,14 +4694,14 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp, if (err) goto err_free_css; - err = cgroup_idr_alloc(&ss->css_idr, NULL, 2, 0, GFP_KERNEL); + err = idr_alloc(&ss->css_idr, NULL, 2, 0, GFP_KERNEL); if (err < 0) goto err_free_css; css->id = err; /* @css is ready to be brought online now, make it visible */ list_add_tail_rcu(&css->sibling, &parent_css->children); - cgroup_idr_replace(&ss->css_idr, css, css->id); + idr_replace(&ss->css_idr, css, css->id); err = online_css(css); if (err) @@ -4794,7 +4757,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent) * Temporarily set the pointer to NULL, so idr_find() won't return * a half-baked cgroup. */ - cgrp->id = cgroup_idr_alloc(&root->cgroup_idr, NULL, 2, 0, GFP_KERNEL); + cgrp->id = idr_alloc(&root->cgroup_idr, NULL, 2, 0, GFP_KERNEL); if (cgrp->id < 0) { ret = -ENOMEM; goto out_stat_exit; @@ -4833,7 +4796,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent) * @cgrp is now fully operational. If something fails after this * point, it'll be released via the normal destruction path. */ - cgroup_idr_replace(&root->cgroup_idr, cgrp, cgrp->id); + idr_replace(&root->cgroup_idr, cgrp, cgrp->id); /* * On the default hierarchy, a child doesn't automatically inherit @@ -4847,7 +4810,7 @@ static struct cgroup *cgroup_create(struct cgroup *parent) return cgrp; out_idr_free: - cgroup_idr_remove(&root->cgroup_idr, cgrp->id); + idr_remove(&root->cgroup_idr, cgrp->id); out_stat_exit: if (cgroup_on_dfl(parent)) cgroup_stat_exit(cgrp); @@ -5166,7 +5129,7 @@ static void __init cgroup_init_subsys(struct cgroup_subsys *ss, bool early) /* allocation can't be done safely during early init */ css->id = 1; } else { - css->id = cgroup_idr_alloc(&ss->css_idr, css, 1, 2, GFP_KERNEL); + css->id = idr_alloc(&ss->css_idr, css, 1, 2, GFP_KERNEL); BUG_ON(css->id < 0); } @@ -5273,7 +5236,7 @@ int __init cgroup_init(void) struct cgroup_subsys_state *css = init_css_set.subsys[ss->id]; - css->id = cgroup_idr_alloc(&ss->css_idr, css, 1, 2, + css->id = idr_alloc(&ss->css_idr, css, 1, 2, GFP_KERNEL); BUG_ON(css->id < 0); } else { -- 2.15.0 From 1584783399469396553@xxx Wed Nov 22 16:13:45 +0000 2017 X-GM-THRID: 1584771088527133780 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread