Received: by 10.192.165.148 with SMTP id m20csp1903975imm; Thu, 26 Apr 2018 04:02:06 -0700 (PDT) X-Google-Smtp-Source: AB8JxZr8h5KC1uag20bt8CZR8Fm/G0c3wqwCfA1QeCiElypGtEtCISnmhxH17TX9vExoXVRVChi+ X-Received: by 10.99.0.86 with SMTP id 83mr4266112pga.29.1524740526831; Thu, 26 Apr 2018 04:02:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524740526; cv=none; d=google.com; s=arc-20160816; b=sSw+BT7sazteAfHzrdKX/Zmw+6mWLmSdvnWYkxxBIQiLeT+w09DIK7Aj008qJMz1/M YVkKksxAhu3HERHf7885oUm0p0x6YvA4UFTUXM6s2K8esYuyHAFrRf9BRPLP+wIuibwD VjZJCgnikQUdv4Wxp57iYdinn/qNYuOoKfT1OLmatwmeL+LDhOv6bpjQNxM3HRr5sy5/ N2r6AeKaJYpEGWC9RUQT84gPMYCi7PuwarYlyMb9A6VCXimnGsj58qBLmBEgW4zYjrTx nWlFkF6djNcQugrSUy+UL4Afdkgn9WwADyBl43pO0huigG4WhpOmQi3v4JY500gAxcLU xW3Q== 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:message-id:date:to:from:subject:dkim-signature :arc-authentication-results; bh=v16fqiqv3C9pGx5UBJrxem3hOZ9yzx4R5blVAuVwZPM=; b=qV4+kqpI7CHGApfFrrzsCvaGhb6ikXC3IiXjmoEOAzqtb2dxCL9xpFMY8A3DnhkLj6 N/jHIsgmSUOtWAZJ/lFu0MXVzPaGoyMlGQ0zLHUX+dU3LQlHSfCESJz5JHAbTi4TvaS5 YBP96ztu3SsdznTBvr7W3J0Rg85MJqtBl/beCWzwhxHLLT/wrzQQ88D+zPsBMMMu8I8p FnX9/+m0l3mfaaR5NmDwL7uITA7Djnq6+FhlUu5SC4ioCh0f+yV7jgL2oOLoWq3MuZH/ p+F4XYwMGllq2Ae84kMkmqeXvB4mto++aGg+ftLFflWQvQ6Rp+ZmM5frKQHVKQcMbIK6 C4Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=selector1 header.b=RrCpccJQ; 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 f13si15642310pgr.143.2018.04.26.04.01.51; Thu, 26 Apr 2018 04:02:06 -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=RrCpccJQ; 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 S1755221AbeDZLAh (ORCPT + 99 others); Thu, 26 Apr 2018 07:00:37 -0400 Received: from mail-he1eur01on0121.outbound.protection.outlook.com ([104.47.0.121]:34400 "EHLO EUR01-HE1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754663AbeDZLAc (ORCPT ); Thu, 26 Apr 2018 07:00:32 -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=v16fqiqv3C9pGx5UBJrxem3hOZ9yzx4R5blVAuVwZPM=; b=RrCpccJQBgGr3G9QcTg6w0ZOoM9v4PFITSbdXRkX+rP+Sczb4favmGwDhBQcq0EW8Ppd2Y+9rXurkgMJNqSfmfZfIHYqKrLq0j/80RUMs8Ym2WuXRnM0quIxYTUP8eLAPlmZeHTN5vmrN3f0ZkIt1HljmZvm7OEg5iNH/T6vg6k= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=ktkhai@virtuozzo.com; Received: from localhost.localdomain (195.214.232.6) by HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.696.15; Thu, 26 Apr 2018 11:00:27 +0000 Subject: [PATCH 0/4] exit: Make unlikely case in mm_update_next_owner() more scalable 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:19 +0300 Message-ID: <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: HE1PR0902CA0021.eurprd09.prod.outlook.com (2603:10a6:3:e5::31) To HE1PR0801MB1338.eurprd08.prod.outlook.com (2603:10a6:3:39::28) 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:HE1PR0801MB1338; X-Microsoft-Exch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PeBtOeN2DAF6IWxcPkzg4nH+qag/w9FXCjO0+VV0fZzA4aAvtZqaNOxzTFJjUS4zrvAvZ538iJ8gLIKZRYfdRKEOacerC1DLUdWxUW78qGpk5UOawDc/wcYGtZ8dV1AK3GhKO55BTcU6slqTK1DAmIkxYIMvTcWpZXXWqP6cjjJHfPwle+82DXqzm9kOXweOC8hNPLpiBxGNAxX+nUSRwEmzFSYsaoREftqc3+mqroorOyWAOW4Ht2ujVfX+YG3I2hwZno4Vm7+sV9+KxpJ9TTy1ytYDwS5J5kj/Cao8lzCtFXqs2bs/KmOfcFqX6EcaqpjmRM4S6TCVS8wJwXIC52ez89L1dDRt3gtY51oXTRKDM8qtPgV2;4:PsomnGgj81MAdyq+233BaHBw8kJ0TBMUIRIuHyne1w1gahyMTR0axzcn71x4eS6/9OzcwM0mLfs8MkUXapPyAaFDnLRsu66bZRIFoPuvQvy7V4T41n3yJb/ctwmZ2nWN5MiIDeoPP+qZAEWE0sCM1O1x7ikDIEWTjRUyOoOC/uIW+H007opt7dPa7wOazzFYmnWHOvJ8O+f9Dektf60MQavgyQ8Dr6e6pT8AHECiOqGTlycjADwN8MgWplcEeJS46AdeXcLly0GQrB/oDR3+nYOisSaIFYAlFW7RH65sWLi5fgFG3AXfosNykfcenOYF X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(190756311086443); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(5005006)(8121501046)(10201501046)(3231232)(944501410)(52105095)(3002001)(93006095)(93001095)(6041310)(20161123558120)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(6072148)(201708071742011);SRVR:HE1PR0801MB1338;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0801MB1338; X-Forefront-PRVS: 0654257CF5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6069001)(366004)(376002)(39380400002)(346002)(396003)(39850400004)(199004)(377424004)(189003)(5660300001)(97736004)(186003)(230700001)(7736002)(8936002)(106356001)(3846002)(956004)(86362001)(81166006)(6116002)(105586002)(61506002)(305945005)(55236004)(6666003)(50466002)(476003)(16526019)(23676004)(486006)(66066001)(7696005)(39060400002)(9686003)(316002)(6506007)(52116002)(2486003)(81156014)(58126008)(8676002)(47776003)(26005)(103116003)(386003)(68736007)(478600001)(7416002)(53936002)(55016002)(33896004)(59450400001)(2906002)(25786009)(921003)(1121003);DIR:OUT;SFP:1102;SCL:1;SRVR:HE1PR0801MB1338;H:localhost.localdomain;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; Received-SPF: None (protection.outlook.com: virtuozzo.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtIRTFQUjA4MDFNQjEzMzg7MjM6cXJwMWtWTktTeGFvWkkraG1xYVRZVys1?= =?utf-8?B?WWdyNWJROVMzdWo1UkZKWUJwUFJYSWZiTXV3RDF5UGRSYWpNSWZzcmxHZ25T?= =?utf-8?B?dklLQ3RGZzZCWXJROWZrWmVwVzZmS2Z2VUw5OXdSdjQwdWZxMUp4SVpISmtr?= =?utf-8?B?eUQ4b0xZUE1HU3BmbmR3SHZiRHBCeGVnNGx3OG02azBBYS83UVVkSFpHU2Vs?= =?utf-8?B?UVdSMmVicnZzT1BlOW0rMEw5K2ZHcXpwZHJmcVF2SE0yUUdlWVFoV0Q0SlR1?= =?utf-8?B?dDBnWFJxdWVidEJzcTNrcm1MbzlYM0R0MmZNR3FZQkdPQm9Hb2luSXhnMk1t?= =?utf-8?B?aDUrTVpBTG1OcGd4VzBCc3JZWWsvU3lodE16QWFyOGVnQ2tzVFN5dzFxT2V4?= =?utf-8?B?TWx0UlJPZFp1Qk9rb08xM1VWeElGeEdaS1ZEcHM1aDNBOW5VazNKS2xVaXcz?= =?utf-8?B?WjdZandNc1dyazhiL25KNy9EWGtIRURMSEhXRmtkMFhqTmNNajRZZm5vNy9G?= =?utf-8?B?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/6aNfi3g01w7f6yM7FvqzV2YOAQdJX1F9JJzr0sPYehSGR4IOmq93inB0Zo7Lgu5/5JPQ==;5:X9J5p9ewZ2CYSJxflJ2vgUf08dmuf40P/8NPgEbBdJ009HTOiXFIXTGdLnECQTW7jWZyGMwC7Tl6qVVGjxuI7dFurtrJYArdIpxniQOD5h0V5N+PpjK9MYtOp6TF/fN2+WtLi4CqEbLOWadNPMut24I8sva1mW7UmE8ifR4t/ko=;24:zHSSCXg2dmBne/zLgc4uFs5OJGnvyqiAY50GpZj3QI0yB9HK8858dEazblpch07+RZz37GkyzBH9k6SdzKuiUXJ2hPw+TqHJHA0B3p+BabA= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;HE1PR0801MB1338;7:99kxvEy0RgdpE5J0y6ijr9S6bvm1WHk52Bd6o1psAvtVOB/YJjFKec2SjR+ccCi59aqoCTCRx38Md+WRqks65Lz+8GsrL48mB20bVkfjMlPmh67KoZtpUEB4KEe/lts5JArz5P1wVr8VSbTljPsYcP8GE4KRoQHXunPEcXLQgGznAp/R+SvEWZ3Zu30ZUlayd3sMAhxhgiH86LqMaomwhY5LfVl8zZ7kELK7jwrqMEgbIkSxuH1yiF7VjIGaDwBF;20:hYIWRjBJCds68Mv9KJIIFAIRu/6qPKIEzp/hziLn7lXT4KfgN3nOvyMQq6J+yi2ut1GSaVQkI+/hID/OV0c2lJk8SE0C6sSrWCJSpfIw9sTiDsf+GjZkPyUw14hHWG/rwOir82Y7vvWquncQWTt9Sex4lPIvWA75NtEDG9imuk0= X-MS-Office365-Filtering-Correlation-Id: fd5f97e6-4c39-47f9-57cf-08d5ab64ebdb X-OriginatorOrg: virtuozzo.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Apr 2018 11:00:27.8642 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fd5f97e6-4c39-47f9-57cf-08d5ab64ebdb X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 0bc7f26d-0264-416e-a6fc-8352af79c58f X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0801MB1338 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This function searches for a new mm owner in children and siblings, and then iterates over all processes in the system in unlikely case. Despite the case is unlikely, its probability growths with the number of processes in the system. The time, spent on iterations, also growths. I regulary observe mm_update_next_owner() in crash dumps (not related to this function) of the nodes with many processes (20K+), so it looks like it's not so unlikely case. The patchset reworks the function locking and makes it to use rcu_read_lock() for iterations over all tasks in the system. This is possible, because of task_struct::mm may be inherited by children processes and threads only (except kernel threads), which are added to end of tasks list or threads list on fork(). So, the patchset uses RCU and memory barriers to make race-free traverse over the lists [4/4]. Patches [1-3/4] are preparations for that. Kirill --- Kirill Tkhai (4): exit: Move read_unlock() up in mm_update_next_owner() exit: Use rcu instead of get_task_struct() in mm_update_next_owner() exit: Rename assign_new_owner label in mm_update_next_owner() exit: Lockless iteration over task list in mm_update_next_owner() kernel/exit.c | 58 ++++++++++++++++++++++++++++++++++++++++++--------------- kernel/fork.c | 1 + kernel/pid.c | 5 ++++- 3 files changed, 48 insertions(+), 16 deletions(-) -- Signed-off-by: Kirill Tkhai