Received: by 10.192.165.148 with SMTP id m20csp1905031imm; Thu, 26 Apr 2018 04:02:47 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ssHqeW5O9Qew8SnrCzswk7Q10XEIpqnsr3E+4JjRNK/ja41YAnilNyYI1G6zApkiCb+4H X-Received: by 2002:a17:902:bc8b:: with SMTP id bb11-v6mr29517165plb.285.1524740567121; Thu, 26 Apr 2018 04:02:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524740567; cv=none; d=google.com; s=arc-20160816; b=TCCw2RRRqZbynY6BUnItHM8eRUQ/HGtiyDZa+l1i8wr7abvkN3uYZs1y+t+iQdFRdK UwANdnfg5wORkWVhQcx+j9lttWQEQUqFJ0+tMV7/3StV3aQ2KakJbZ5ioolNPBrxXKv2 L4hD5y3VbuGLAqB9KzWmg0lxmcg0JPxgrUBvcloGYqTC9QP8g331JWTlqJvQZZ487RO3 nuCg7Wt7gr+EsgL+ZcyMNnGu6CqjhuUFw5B3X8ynpKi4SVvoeYZI5uEKqrAhpdL0xRgi LfEpV+aYr+mG2RANypJ+s/PNMYn9/Vcve9vMXs+VKnvVq8Q3idj2naygK836kGhZnKwI Xlew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:to:from:subject :dkim-signature:arc-authentication-results; bh=by1RxEM3HkNzwtk7I4JilkTWIG/0B25xvcGGit7U9OM=; b=enB/G1lXGxC36m+VNkHL6KJ/sRcoBfSesCQzq6HR544j+dP4WfoPXekSuho6IiXKRf GULsfTHa9NXYzpp7fV+2OdSVNPkD3fzgfodWqqUfTVon4AeqUby3nlY4TBK/go0EmqMD jOQi5GgXmhiB2HbxxhLbMhDCUkVBiUrxji654AgsehCb8u/l1Apcx4PKha5a9hoMTABv abk7PZyQMBD7HcM+Flw/+3I8hzVqzn1qIzdtg5vlt5b8IbxmPXgcCaqLbXyuyZ+RROIX bUIIk7nEAE1IFv70QuajPa2Lqg18N4tn+r5rO5oe/6b5/AGhA9h3G0QyOXJHwBSWZiit YdaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=LSlgG0RG; 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=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u14-v6si4396885plq.439.2018.04.26.04.02.31; Thu, 26 Apr 2018 04:02:47 -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=pass header.i=@virtuozzo.com header.s=selector1 header.b=LSlgG0RG; 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=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755461AbeDZLBD (ORCPT + 99 others); Thu, 26 Apr 2018 07:01:03 -0400 Received: from mail-he1eur01on0111.outbound.protection.outlook.com ([104.47.0.111]:58811 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755352AbeDZLA5 (ORCPT ); Thu, 26 Apr 2018 07:00:57 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=virtuozzo.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=by1RxEM3HkNzwtk7I4JilkTWIG/0B25xvcGGit7U9OM=; b=LSlgG0RGW5ZdiK+np0jwKQQoPf67sBN198J9ToL+2YN63lxm2Tg8Toth8mcSsrigdBcIbJYW4iJ2ZTUyVwPoJPbREQ3RTZ601FZ+QIul6T7LJX57NdcMbk2wx2Yro22HEssORaSYMtllYtfRt6ucmH8Nl1sp+RzLfiRsHanXJXs= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by DB6PR0801MB1336.eurprd08.prod.outlook.com (2603:10a6:4:b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.13; Thu, 26 Apr 2018 11:00:52 +0000 Subject: [PATCH 2/4] exit: Use rcu instead of get_task_struct() in mm_update_next_owner() From: Kirill Tkhai To: akpm@linux-foundation.org, peterz@infradead.org, oleg@redhat.com, viro@zeniv.linux.org.uk, mingo@kernel.org, paulmck@linux.vnet.ibm.com, keescook@chromium.org, riel@redhat.com, mhocko@suse.com, tglx@linutronix.de, kirill.shutemov@linux.intel.com, marcos.souza.org@gmail.com, hoeun.ryu@gmail.com, pasha.tatashin@oracle.com, gs051095@gmail.com, ebiederm@xmission.com, dhowells@redhat.com, rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org, ktkhai@virtuozzo.com Date: Thu, 26 Apr 2018 14:00:49 +0300 Message-ID: <152474044955.29458.13116121113099868575.stgit@localhost.localdomain> In-Reply-To: <152473763015.29458.1131542311542381803.stgit@localhost.localdomain> References: <152473763015.29458.1131542311542381803.stgit@localhost.localdomain> User-Agent: StGit/0.18 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit X-Originating-IP: [195.214.232.6] X-ClientProxiedBy: HE1PR05CA0216.eurprd05.prod.outlook.com (2603:10a6:3:fa::16) To DB6PR0801MB1336.eurprd08.prod.outlook.com (2603:10a6:4:b::8) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(5600026)(4534165)(7168020)(4627221)(201703031133081)(201702281549075)(2017052603328)(7153060)(7193020);SRVR:DB6PR0801MB1336; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1336;3:IifCW+/0zXnjXXL2RuHKc+U98GmkgOG3HcN8BfPtehbkzdKz1ytz6ywSpLG6aPrz8sK8dEjb6/KzHEbdb4ZqVrpG6PR+ku4IWnBSmasKTdIbhBfS+kczhBl6mE2jMDy+z4FhVe5NG1Aml6BQJvBBCe36MwKAnbjhu6VP+v+yfZv0lOWsjYwyktiHCi6MEOHJSX089jOow0FYEisCdjwyeBU6kLqGwH9GEFP17CGWXWM6VQSVjIRfxsE7+9FUq00X;25:4rahfUi7D43C6F1vz7FlKRBq55m5Y5Xwz+w9Nktg29KXAC12KvGFccvoaqOjFC9CYnTV10E3epy77yF5Eqvpejnm2SIrCPT1LuMg+mSiorFXy/IjOyi5S/y7Q3Gaqbn6xBwhchFxLUCJlurSSpO2lYFo5SC7m0WYsyunXYoSD9DbEkTUqgKr4SeoFgqwfD6KQiEOOywLoqawHYmGqcfj6FmZV17ZO6RQA/MgB8zeQVC9TTVHVoaEibboyYmN1CzG6UM5ZTTsD+kdzPiwMa//vT8Comj9iYlBFens9c2Me1wb0c7ezto9dx7Vprwu/NEh+zPkuB9qixDoteBEBxHuaA==;31:VT42obBAKv/XjG34XdwZGdshHKKq0YteVQkESd+Mhp30HIpP4aHH2/8mklZH/KkJWERsdj3lU4Q4hG2WopL0SfzZBK3cA8mKifVXpCza9KfzaXh51GyrovMCvH87CVndvEWyyYyQUROU2/kXzXE8g8yjc+FfndT0OiE9mzRxKH3nps8RA5ef4VZ0DTDJNHqc5flw3dmMUQ3MpLrXvuyg6DANAptRD5h7J2k8bQoEBIE= X-MS-TrafficTypeDiagnostic: DB6PR0801MB1336: X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1336;20:abxh+sE1Liplb7zwoWdkuWJq4ulNBrYL2I/bYizGoHQv/wL04Sf0f/4SLVSOSe2f7SK+C7ob8wG8LCZwjZQERjZN+VVfLnnVUle5fwHycLhdSVj6uIOMA2r9KV/PoF25IQlD2S775rlKhOuI2Sg/zm1xQT8NRoGX3cnwrjY7FUOKzchaBZ9DaFpkG5WLIW7u/ei7ltZUHObRoNon01iXTIRiv50UEKYeA9C0p2BVWS92bE8j3v9SoKUCjd3kl3HvgjHhh9ojmRRtGJuB3dQ5IDzFDmMFcvGvm6vs/HFygUqMKfMeNBYwHAzTrn1m3O0Z+QyU/zlX96b37iM2T/6EK39A+69HeS/Sj0GipmasxxquxqEz7eW+GkEbES6Qu4gpvtOE9ZAMRQP8x4XuRth5i1pYpITyYbTvG6tPCCHA81wiLivp9jSsWZmcgUS2F65d9dImpHHPeylsO3Oh+MdIkMoO4QVNaW4kIs/98Mw+engTfQr54RdP3OCYkadwDiK9;4:XxdV3w0DeLH/uSweaxXG4sXM5iLLbo8xzOhzXS4Tb3wcivi8nSepJ2xicjUGsIgrNsEqi58YSwX8Ip6JJtIyQord4C6EjrYvSeShfjTv5yaGitlwWftfkap/jHLKkHhhp3AHuXO9fWjETg4OeR6RK4+bD9Tb2cwIWqh7s7b8YWfvhj6qAiSR9ji+LHQlMu87gzxlk7l4exmnbaoeJ0G2itN/LwRpiCXr/TSYTkVQ6AmMcgDeLwnd9pfQlZtdx29AI8G85vXn/UPjcjnOV3vyJg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(93006095)(93001095)(3002001)(3231232)(944501410)(52105095)(6041310)(20161123558120)(20161123560045)(20161123564045)(20161123562045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(6072148)(201708071742011);SRVR:DB6PR0801MB1336;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0801MB1336; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(376002)(39380400002)(346002)(366004)(39850400004)(396003)(189003)(199004)(230700001)(58126008)(6666003)(50466002)(5660300001)(478600001)(7416002)(305945005)(3846002)(39060400002)(97736004)(103116003)(25786009)(66066001)(6116002)(55016002)(53936002)(47776003)(9686003)(105586002)(2906002)(61506002)(106356001)(16526019)(86362001)(81166006)(68736007)(316002)(81156014)(7736002)(8676002)(6506007)(8936002)(956004)(59450400001)(486006)(52116002)(55236004)(2486003)(76176011)(186003)(11346002)(26005)(446003)(386003)(23676004)(476003)(33896004)(7696005)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0801MB1336;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjA4MDFNQjEzMzY7MjM6VUhvaUFNckRva09JeUV0cm8yR1FsektS?= =?utf-8?B?MWhId1lyTlFCdlN6V2lSQ04yb3FhZUwzV08vSHRUQlFIaTdlcGs1TWNSNUdT?= =?utf-8?B?YWdtV1FYMDMxYzhBQXZSRDVLd1prZndpZjlQY3pGdGRvS2htakp5eWU2TjVS?= =?utf-8?B?UUtsbGxVK3ptV0FiUkQ2aStJVWNUTlo3L1Fza296Vy95VnlMZXhjSk04Q21T?= =?utf-8?B?RWJmYzZlekFaUFpDK0xVQVFBR0c0SzlEQVY4WXdKZ1hDdzVtbGFuVXQzY2cx?= =?utf-8?B?RVpaU0hVcVU3eDg3STUxSStDMTZTZUdPajVIKzNuYUFMSnlPdGJ4N3BJVFk1?= =?utf-8?B?Q0lZR2ZOVmtjRG5oeVdCM3BuMG9TN09BRERMOXhObEtxd1FDMXRSeEpIbHQ2?= =?utf-8?B?d1QyVldNRTAwTEU0a1JUekxoeVkzcU5VSVNkVnlUek55eWtlSWhOVUFSVWlL?= =?utf-8?B?cEViQkN1cTY5UWI2d2xIU0R5d1N4WFVUZTg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571KcF252VbxTukmD072udOiG9CnCfY1UiXRDZZzQEIIXoORoXs1X/qGSMKfUYZhKt3s50x133DE0o4n/IPqgYOCiRmQRF0hhN+1tj/tFbP1MKZ2nYlSl8cQkkHPuAaFCrYyV0DwzOCQlH3YEU3tmNFkJY8jQ==;5:dQQlvuO8Al5mLsaP22D4AiT37J78hCSH1fb5sxeTPV9kxsiDs4wW8hXaCDKBI5k3COyQY/gIPLF3dfRPebGt+2oePbnZV/ml0kZ711PCHl4BNExnh1o8v4iau/JYH94w1bsAWq0s194219mvFsvyx1R0r5K/Ghvg5Y88C73EZs4=;24:vwVZPKn9pGqVxCnMAb8x0zmTsIXdMGSN3m5DOhTMvdZfzfuCLlmDGChOFaB9zikdZD0Zye7Hc3mVHaPr6WF6BhXqoXAM+9EXoFhq2cvJ69g= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0801MB1336;7:z5fJB6yqT3wZd63ZKWNp8hOcqT5l9Z0fuUYOKtr4/ISb0xMLBFUKSarsj4FSY6SHuiy0eKSYh/nkg76yCszwrZE7nAMTUnV6LJm6yybVhYaAxFRwPRALcOf23u6t6Pkbl/ROx/abjxscMR3Q57op349ZUhp4sre9YF/NC/jmg6RWebubGIXmp8TMf1Unz/F8a1cYru52e+AHyV2PadXrF9IyijNX+6QG77/rPtm7yfuCWHNMzf880ZO6gaVQR+2h;20:/IHkAtd/YOYkjO+neQXtVt38tJh5X2jIpSSCDIvUUyxnWEwHcfC6owYqHVngT1O4rakKvSJnmee9tV0+H5G6zRdJIIYqvKbDnHjS5RdGt1/Zwh3qm32mOq1IGjqrqyDlEBh8t3tZ7Ro9kiWp5VC422qAJS/gblSJ1guSQq8Kv/U= X-MS-Office365-Filtering-Correlation-Id: bf06c0b3-16f6-497c-b74e-08d5ab64fb35 X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 11:00:52.4346 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bf06c0b3-16f6-497c-b74e-08d5ab64fb35 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1336 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Since release_task() puts final task_struct::usage counter at least one rcu grace period after removing from task list: __exit_signal() __unhash_process() call_rcu(&p->rcu, delayed_put_task_struct) rcu_read_lock() guarantees nobody release task_struct memory. So, it's possible to use this primitive instead of get_task_struct(). Signed-off-by: Kirill Tkhai --- kernel/exit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/kernel/exit.c b/kernel/exit.c index 9fb7b699bdeb..5c42a9b9c1d7 100644 --- a/kernel/exit.c +++ b/kernel/exit.c @@ -464,7 +464,7 @@ void mm_update_next_owner(struct mm_struct *mm) return; assign_new_owner: - get_task_struct(c); + rcu_read_lock(); read_unlock(&tasklist_lock); BUG_ON(c == p); @@ -475,12 +475,12 @@ void mm_update_next_owner(struct mm_struct *mm) task_lock(c); if (c->mm != mm) { task_unlock(c); - put_task_struct(c); + rcu_read_unlock(); goto retry; } mm->owner = c; task_unlock(c); - put_task_struct(c); + rcu_read_unlock(); } #endif /* CONFIG_MEMCG */