From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DE56EC2BBCA for ; Tue, 25 Jun 2024 22:22:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4D0DC6B008C; Tue, 25 Jun 2024 18:22:02 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 458E36B0092; Tue, 25 Jun 2024 18:22:02 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F9356B0093; Tue, 25 Jun 2024 18:22:02 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 10AAE6B008C for ; Tue, 25 Jun 2024 18:22:02 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 80E581603F8 for ; Tue, 25 Jun 2024 22:22:01 +0000 (UTC) X-FDA: 82270834842.26.C7F995F Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf13.hostedemail.com (Postfix) with ESMTP id 1578F2000E for ; Tue, 25 Jun 2024 22:21:58 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=XxxtbFFP; spf=pass (imf13.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719354112; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=zC5zeOsIels7jaOTstmxA9kMdJSSlgS/DvSqZItgNkE=; b=eu3wTo9GAMrTGzjpzuNNJ1U8Cw1UtphQl7o2zec7FPwOrWxUFh12wtSxOHsNPAQ4n8XYu4 nK7GEmZIpPmHDWkUftSmKRHLO8sjV9FLDrTEeTCyJuporr9F0p79RB+T9nlqRYppnHXhzI YNR3C5T/cRFUiWeboh93gbTNvK2kVHE= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=XxxtbFFP; spf=pass (imf13.hostedemail.com: domain of akpm@linux-foundation.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719354112; a=rsa-sha256; cv=none; b=0fG+ubQvbTcmIChhOa6z8mRcvsboeu8SnbTZO++3wS9Nce3oLYMdzhVPPPYKEMkJ+7+xHp Znt98DieYGKZid/u1hzWiwLt6p4vlCQyfNJwTf7slmXbqaBHvoMuEoY1ZGRcMy0EpN8nLM 0O91V9g17tU+1NEApce0EjDvmuNuXJE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 8CDB1CE1F83; Tue, 25 Jun 2024 22:21:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 797B4C32781; Tue, 25 Jun 2024 22:21:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1719354113; bh=IWOi2HaQdIy+DK2/fP1UtD4ZDDZLRzBu5H/o9BGRBhA=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=XxxtbFFP3AHRu2SnTKvNoVWOL7ZsHc19Rgbnv9soq0CdHpPJIYzb7x1qXh87E+S6k T4W/ZKg3GhGSjismlc+1zv8zivTlohdjjCDT12HZyo5mF1VQqK8TONIoVuEdf2VBAp aA54DFSQBqDd7tf9za5kbeO+3rQzQwDY7o+YCTj4= Date: Tue, 25 Jun 2024 15:21:52 -0700 From: Andrew Morton To: Michal Hocko Cc: Oleg Nesterov , alexjlzheng@gmail.com, "Eric W. Biederman" , brauner@kernel.org, axboe@kernel.dk, tandersen@netflix.com, willy@infradead.org, mjguzik@gmail.com, alexjlzheng@tencent.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH v2] mm: optimize the redundant loop of mm_update_next_owner() Message-Id: <20240625152152.89381ebd8f3fda856a320f72@linux-foundation.org> In-Reply-To: References: <20240620152744.4038983-1-alexjlzheng@tencent.com> <20240620172958.GA2058@redhat.com> X-Mailer: Sylpheed 3.7.0 (GTK+ 2.24.33; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 1578F2000E X-Stat-Signature: 7jhmwb8e4kxjeo34zhd7yjmrjs79pps1 X-HE-Tag: 1719354118-440800 X-HE-Meta: U2FsdGVkX18oymx7YcKZlvNdV77Roc5MFgpmZgCsDpESX1ulqsUy30Q9t6RUiKS62LkGGKyOhIWEQqNOZCX3BGfFLwb/ljRSVHrmdD7rbCVfu5o0aBg8mkDNURMl+2EaiuyJ3JgE3NhAnqSo6APM/979s+hxjaIZYfqq9RSntitD94qo9V3Uf3jxRyFRXjS6P5PUXbqyaipw06UfW9zymGHNgb56Z0r/diSplorglxNDgZ+/enMWN1aUf0/VSoZvoowVBz4bVQvgORSbnFYtF0b2gMpMywy/5OfEE5aZvEcQHc+PeYpI1fd1Hpy34H73+6YdZFepmye8TZAb+4yIto3p5I8mGfPnUhjoAFaHTR6+9QjSETgaxf5Hxp4dGZBPhjGEQDVPdY4wathVeMBNYSleWp1nEq+L9mso3qoW3Mtjc+AOJyHmspz05NotxR42wOYQ0F1YPasREAIH2m7mCeB0ZJRX9u65jiWHZit16GWnfWnQEyWF4nQdtI2CPLEhodaOz78OeVBzATJ0M4fsfx9rVh9nuFIK4GQG4IDSlEWbccOIOn25pGykk+zo+ZnhexPAcT8IeUIYOR11T/2K4LBtfDzc4w+hp6Adh1yMWgxOLdH7MFGZrCZDgpY1xx3VR/oPiVyCNm1K4g8/+IoaJY+Pd7JQGQOsxYQ199Vnrj3rXEo20lJdkDn6SA16e1LXz5c+rqFsgD5kHQJWSadT5PRMCcgdevdRyKxE2Vs2ayZr48ONxuQFGtstOyDjv+/7pgc5gE3x3ph56px/idPyCV6Wf25uwJjmXmW4pkof3aXdx0eCnr9FAVWLKq67vKqf2R3wMBvJsBh9NX5YJHww1npm5q2DnOCLdenstZ5GqyLnamhLZdRiHxvuX9Jta3hKFhMCJwBPHm0DUCtiD5RNPEU60tAEfdS7yQvXjIhSuiFVnGGrgpK8gO6wa/uFNzKUF5kEwZdLhVvno94JsF/ I2zOwIAt r4Z2irz2E3HMc3q2cIiPql/OOanG0+/S6ErlCqYmGvR/7SgTzR2P8RV0mPVZ3MuFQwt7irij0a7TiGDjBnENXw3jP4DkMqdzAblvaUfvB/qj/+0+hKa7EzOErXibduPA0U1npmdWE+CSF6SgmJbLaasGgd4xvOppVd3/LEqzzqOZGSl4LQelXSnNMjpK2DXtlySmPfb/0R4B8eFAq9Jhr9PtgxDYlOTPmw2VTExpEvmq9t0mRSDjzCwV6vT1TW+wwex36Jhq6wuP/PX2j7JHn2hOGJd9vCFwEjxE+1pH/7vOQzhWpAfkcVv9EKPiblTsyA5AR8gpr86w49Ww= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Fri, 21 Jun 2024 10:50:10 +0200 Michal Hocko wrote: > On Thu 20-06-24 19:30:19, Oleg Nesterov wrote: > > Can't review, I forgot everything about mm_update_next_owner(). > > So I am sorry for the noise I am going to add, feel free to ignore. > > Just in case, I see nothing wrong in this patch. > > > > I think this deserves a comment to explain that this is optimization > > for the case we race with the pending mmput(). mm_update_next_owner() > > checks mm_users at the start. > > > > And. Can we drop tasklist and use rcu_read_lock() before for_each_process? > > Yes, this will probably need more changes even if possible... > > > > > > Or even better. Can't we finally kill mm_update_next_owner() and turn the > > ugly mm->owner into mm->mem_cgroup ? > > Yes, dropping the mm->owner should be a way to go. Replacing that by > mem_cgroup sounds like an improvemnt. I have a vague recollection that > this has some traps on the way. E.g. tasks sharing the mm but living in > different cgroups. Things have changes since the last time I've checked > and for example memcg charge migration on task move will be deprecated > soon so chances are that there are less roadblocks on the way. I think this was alexjlzheng's first kernel contribution and as such we might not be hearing from him(?) again. And that's OK, thanks for the bug report - it helps Linux. Meanwhile we have a stalled patch in mm-unstable. If someone could add this issue to their todo list, that would be great.