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 4009FC30653 for ; Wed, 26 Jun 2024 22:05:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AACD66B0085; Wed, 26 Jun 2024 18:05:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A5BBB6B0088; Wed, 26 Jun 2024 18:05:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9247F6B0089; Wed, 26 Jun 2024 18:05:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 732306B0085 for ; Wed, 26 Jun 2024 18:05:21 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CA22CA2647 for ; Wed, 26 Jun 2024 22:05:20 +0000 (UTC) X-FDA: 82274421600.22.AB6121A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id 0F5C1C0008 for ; Wed, 26 Jun 2024 22:05:18 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=M2Sd42ei; dmarc=none; spf=pass (imf10.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719439501; 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=pnFeOqxrNnTgZgF9VgqQDQDarUjrRoI5OtCpnqkBxxI=; b=waHWiGOWYHh1fPbTPr+TiRUmEnHVmDxSLsJ3ZCnrLW9QmquwRLBUJ3WOaFdUQorx5edHKi aDxg7zF/znAQiZwZl/BbcZNx/K9Cw3zCps0pt2jFhoVz0ECH78YRCfvae+llXYpuELaQlr AxF65qll7KD7YRIU+OUEgU0Pxeo/IoY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719439501; a=rsa-sha256; cv=none; b=B1a+ea5yEvld5VntHFWuWcnidTyxtoBQ8seZjMZg2qoyOoIwYx3lCxLTmpadKzC6xkvfs0 pp2xrpoux+Kxu4UyNVUEEFDjHgq3ojADcCGIoR7M/EG2nYVjZHI0bMeDu5PaSEkknhPnSt xUS9twOE1gXSSRGLSwU7Mmg6B6QvtnM= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=M2Sd42ei; dmarc=none; spf=pass (imf10.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 1C00761B60 for ; Wed, 26 Jun 2024 22:05:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8E9ADC116B1; Wed, 26 Jun 2024 22:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1719439517; bh=jkxRntFuaW4JvkXSVFtxygzIMltJr+aE/04dsBHFb94=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=M2Sd42ei168CkIcoFj+EnXn8NFVRO/GBD28yMg2UOJutE9w1z+R75Jj6hyqVWZszB 953lA3OhFL0avCE4wm2nrLVjw5iwDyPvhaFSU+LUy1ffVI8niqW0NOnCT7514H468E rAwzsVeKtONYgjsJMDzZplBo4OG75BvMjtXeq3TQ= Date: Wed, 26 Jun 2024 15:05:16 -0700 From: Andrew Morton To: SeongJae Park Cc: damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH mm-unstable] mm/damon/core: increase regions merge aggressiveness while respecting min_nr_regions Message-Id: <20240626150516.fb14ba5e65ae9d59ece0d390@linux-foundation.org> In-Reply-To: <20240626214954.46143-1-sj@kernel.org> References: <20240626164753.46270-1-sj@kernel.org> <20240626214954.46143-1-sj@kernel.org> 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-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 0F5C1C0008 X-Stat-Signature: sj7ii848r1omjykf8a7b3w81cufda3r5 X-Rspam-User: X-HE-Tag: 1719439518-523777 X-HE-Meta: U2FsdGVkX1+S1KEdI2T7vjl7NXxDUsbrE13T2IyjYS9ulpSH9xNPUStxPK756xa6rKflscIebZ+W+BlsTnbMHYZLhwKBy1f5t1Yy/0Biq33U+g9RgHsug2EP3vy/89JFBdHwVDPSKSVY9Hja4BFdh777aycPo4YD6VR5noZhy77uXXRJcMJnYH1xm4HbeyxL6QvDh9JEEV81uOQmvr+oIzBldVgsVXXFjWw+IGe88BvbiJyk+UoDvjFMOtqYNdqUDPYvdYa1b79xBC+oWzdWnjBqz3Xms65utexXRYCDDUW/6DWm7Fu8I3IpC5r7xOsXsO3xU262Hn+Hoe73nflPQ2dK+XqwhT2BFYoDnXDQLlpFCeLUABWPqe18w/PQq/EvtGlFtpo/nTY4gl6rxPHqYv9OYKXvya8Ncb1qFHIerQ//+rCVUAiX6mDJEJfRwv3bmth1+UafSrgBfe5zXPgtiPDKc5oqLqbMOH4eTai8tO9XpZyQNc7LpqkMagZY6zGD6Pt76U9dX2vhzSv7cSkd0ypZl96QOvnd+nZlziM7sg7dcAiL2bCsnlKd8o56tGtIj1TWERzUkk/9D2ig2vuZ7riY6i1XAHap6nvbJomUTctj0EuPo06htSY7i3B9DNlD2OvaAdvvRu3ewXLB55TzrgGumz/5PYJJtEyaKoxjUFPcZP3R5mrr6XD79t31FchmnA1ofpJreNn2NEeKR/h8R6CHtfmBVyEkKnrTVp97OHPEPPGI6qRKujLpZeKoGn32UvB8ktl0dFYMia8+ESG0K3YFQQSVoTm8QWc22MKdEfCwVR5bzljkjdWd7NdOs07EITOD3bq7JWP1UcM72iv6Wt13aiYzi72O0WvUEZSQR4LZfx61TYaL1gHKfkZb+sVuXv7gQmoTY8Pz6KsXYxvVCNWvMAOXvir5XROhwrDIgcjSFhIv0OG6Ae7uheF8QEkPmLItFWgTizBVEyvu+IS lFdNhwzb HsbsEnEGL6sytlCa3gxbY9sHiszr098yvc3FAL+pQ0maThitg6u95IetjkH3UzMHMCw4Erm/iXAlf+3nbXqLjoJL4DEmyTx9h6ULXFCCKnRP09fqcfAhLJ2OjhidmyzOX5LdL1OJ6VRsJt9AUj83ryQGu63IXIUbA8WdogxGl1j/AcLTzVi0kCUxi2mOkNf4r+22rkp9yGjGvdwA9+gf5hFf3xYU8FHZm2b27AwrhNN37wOS9WIWTzESuPVKwLkF4hyJxn5zBeD36SCVrrAXnz0zs5ekyvkJ2ctei4atHi95a5VX7W0ybv1iED559rD1hfO41eJ93F6gJ0meEvH7Kp/D0s99BulhkpBk1HGS4Jt9LOPkQXvZrqUhb9pIOxrx3e8PJmh5JqFqPexXN8BVtdiLt8A== 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 Wed, 26 Jun 2024 14:49:54 -0700 SeongJae Park wrote: > > @@ -1716,8 +1717,8 @@ static void kdamond_merge_regions(struct damon_ctx *c, unsigned int threshold, > > nr_regions += damon_nr_regions(t); > > } > > threshold = max(1, threshold * 2); > > - sz_limit = max(1, sz_limit * 2); > > - } while (nr_regions > c->attrs.max_nr_regions); > > + } while (nr_regions > c->attrs.max_nr_regions && > > + threshold <= max_thres); > > This code means that kdamond_merge_regions() stops this repeated merge attempt > if the merge threshold that increased for next attempt is higher than the > possible maximum threshold. And because the increase of the threshold is made > by picking a maximum value between one and the last-used threshold multiplying > two, the merge attempt with maximum threshold will not be made unless both the > maximum threshold and the threshold to increase are powers of two. In maximum > situation (e.g., region 1 has 100% access frequency, region 2 has 0% access > frequency, so on), this means the max_nr_regions violation cannot be recovered > by the attempts. > > This can be fixed by changing it to stop repeated attempt if the last-used > threshold is same to or higher than the maximum possible threshold, like below. > > I'll send the fix of the fix as a formal patch soon. > > FYI, the original fix is definitely better to be merged in stable kernels, but > not urgent in my opinion, since the problematic case is not common and the > behavior was same since the beginning of DAMON. Andrew, if you feel the > original fix is not stable yet, please feel free to delay moving it to > hotfix-stable for one week or two. That's fine - we can merge cc:stable patches any time, really - they will still get backported. There's only a hurry to get fixes merged up if they're security-related or if the issue is causing people problems. In this case I'll await your -fix-2.patch and we can merge the patch next week.