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 ABA7AC41513 for ; Wed, 26 Jun 2024 15:25:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4521A6B0089; Wed, 26 Jun 2024 11:25:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3DAEC6B008C; Wed, 26 Jun 2024 11:25:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AD936B0092; Wed, 26 Jun 2024 11:25:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 080236B0089 for ; Wed, 26 Jun 2024 11:25:32 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B97531C2DA7 for ; Wed, 26 Jun 2024 15:25:31 +0000 (UTC) X-FDA: 82273414062.16.3511433 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf23.hostedemail.com (Postfix) with ESMTP id B8C6414001B for ; Wed, 26 Jun 2024 15:25:29 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hpUITXxU; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of oleg@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=oleg@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719415516; a=rsa-sha256; cv=none; b=h+a7V0cqTzgQAemMbgct4FPiiXkjqpYysRgOvDkYDmXm/F4SDT0mjQ4AXetuMwt+vXNrSq FVPvAUPxxfwWEpFhpoGDVpiTr2b3hc9U9nJ3d/apQmCuRdJ3unRWGajt+RBYePlKVOczZv Y91qa2HvFG/t+BalETjTOdUEhB81Gaw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hpUITXxU; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf23.hostedemail.com: domain of oleg@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=oleg@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719415516; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=n2eyTmEVbUI0DY39yr7MWMW2MvOH5CtjCxH/a90cE6k=; b=5KjFzyVhwROZw+yV5HQbyWB6Ndrta+zdnPRRunV/xOgbt2NINUDelOV50lr0M+iGj9OCA2 aDsOx2WriXjAqLYc4IHPv0VnMQ56/fPi7uwx/Rswn3MNO51+B5Q10a14ZCqlt+TmI88wqn vf2v6BCDmmSMJfvClU8LcRy1lto5s6Q= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719415529; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=n2eyTmEVbUI0DY39yr7MWMW2MvOH5CtjCxH/a90cE6k=; b=hpUITXxUbnxDfa9Wc1pX+vthZ4d6EqOlUSVC1YPNPGE4ou1Fmr0htQNC+dG0FOBh+KQY94 sPFH85xl31C5c8+Fnr2FT7TpoKRyZIssorK/BObIlb1mKFcqdbsJRa6oGmosn0FT1+Palx czH1+TUC5/zHO7fk28AzloRoNa2yTDY= Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-584-mCYyMfNuNlmYKRw9ZOZTDQ-1; Wed, 26 Jun 2024 11:25:21 -0400 X-MC-Unique: mCYyMfNuNlmYKRw9ZOZTDQ-1 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 996BE1955F54; Wed, 26 Jun 2024 15:25:19 +0000 (UTC) Received: from dhcp-27-174.brq.redhat.com (unknown [10.45.226.94]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with SMTP id 98B121956057; Wed, 26 Jun 2024 15:25:14 +0000 (UTC) Received: by dhcp-27-174.brq.redhat.com (nbSMTP-1.00) for uid 1000 oleg@redhat.com; Wed, 26 Jun 2024 17:23:46 +0200 (CEST) Date: Wed, 26 Jun 2024 17:23:40 +0200 From: Oleg Nesterov To: Michal Hocko Cc: alexjlzheng@gmail.com, "Eric W. Biederman" , akpm@linux-foundation.org, 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: <20240626152340.GA17644@redhat.com> References: <20240620152744.4038983-1-alexjlzheng@tencent.com> <20240620172958.GA2058@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) X-Scanned-By: MIMEDefang 3.0 on 10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ePFHMAbACO6wuF6Br9ZoSfT0RKSegYBHu FAz2bSeb D6VOpGnGL0tx0KkkfZxUJWBHFvPMeaPqiNUADmIp/L6nMFU+7VmpNbiQ9eZLWedYefHMzVlXMOMBHuIEWKrnujKOP3c3IGqXia1YH7+i5tE8kfPRXY9pRyn4O9+hS2o5s+l9nXjxNiO7+pblM/ZHCDWzjVbLGT343Y6q6d1ojvaq0txPEo80JzgCsK69sLHdXoEHx7WXfaZtSy1Nwe2Y0scrRBx3GWBwkWhsBN8fYiSsudid2tGwPKR9ApjSbRhzdOqC+hGZSjZlkqVhpcLdMIDUfH7VtBQzvmGh2ZZeS+V5AVr3Mhczv0CTrqqwAxZHYuGY5Wd6Uxzfgx4aS9pm4hjk8RQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000115, 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 06/21, Michal Hocko wrote: > > On Thu 20-06-24 19:30:19, Oleg Nesterov wrote: > > > > 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. OK, thanks... So if we can't do this right now, can we at least cleanup it? To me it looks just ugly. We don't need get/put_task_struct. The "retry" logic is obviously suboptimal. The search in the children/siblings doesn't handle zombie leaders. I'll send 2 (hopefully simple) patches in a minute, could you review? I have no idea how to test them... Oleg.