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 4CF07C6FA82 for ; Mon, 12 Sep 2022 19:26:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 934168D0001; Mon, 12 Sep 2022 15:26:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E3366B0073; Mon, 12 Sep 2022 15:26:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D26A8D0001; Mon, 12 Sep 2022 15:26:42 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 6AFDA6B0071 for ; Mon, 12 Sep 2022 15:26:42 -0400 (EDT) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 414A51A0156 for ; Mon, 12 Sep 2022 19:26:42 +0000 (UTC) X-FDA: 79904415444.24.1214348 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id DA37F1C0094 for ; Mon, 12 Sep 2022 19:26:41 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3A706127D; Mon, 12 Sep 2022 19:26:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B63DC433D6; Mon, 12 Sep 2022 19:26:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1663010800; bh=+KE36g10OHpuTg9RLmHGCa2Z6Hs0fenFn9IVggo2Ao4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=S1Dkyxk4tr7+QgJpNp5Htd8OAnRf7PWC2kayDlmAUaWd8bP1QDAgCb1IBvgx863xw v3FKTP9SD0FzT3E0RTkO8eFaJJyl2Wep4a9PoeR+mkku1FOYvHwtu0dyQyULI8BGvm NUiv4U/fBXTVHcCaAVrghMgTvFq5hJ9eiFf8Wa1w= Date: Mon, 12 Sep 2022 12:26:39 -0700 From: Andrew Morton To: Dawei Li Cc: sj@kernel.org, damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] mm/damon: improve damon_new_region strategy Message-Id: <20220912122639.6c8363ee79f3313299c9446f@linux-foundation.org> In-Reply-To: References: 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 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1663010801; 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=h6Xpae1eyuUQ7qEP3C3e63RYP90pweoOIS65qi40OsQ=; b=Ft548tuadFus6/pff4uwpZVNYBS0obBUOTml/2KyitOSu6tv355cQpEpqwUV6cwnO+JCfe xUsNLLmYYpOlCUuJ0lDlL8yNROOEVfJ3evFS9aM8yI4xW6Z6SoXL+b9lLEzmyx89v5UU5Z vJnN2XWkSKe9Y9S4fTDseZ+jrPLEQqM= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=S1Dkyxk4; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1663010801; a=rsa-sha256; cv=none; b=MDs9LycZI20rt/5/fphA2mb3C6HQ6mBjYP8O2pvQchrcIEg2CJ0LpoiiFS6fAAs8ml8uo8 C1Cm6ES5zxNyUoqAKVGxqSdmK5E4jDBHOLPBAEZ/JCm1nZPEAaCxkxfYlRccWyw8VrzuSm jPYmuHg4ufmBdKJa8nySRrA7oRpN5LY= X-Stat-Signature: c4nebdw973q15ozpr5yuwijuuyw8t7s1 X-Rspamd-Queue-Id: DA37F1C0094 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=linux-foundation.org header.s=korg header.b=S1Dkyxk4; spf=pass (imf18.hostedemail.com: domain of akpm@linux-foundation.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=akpm@linux-foundation.org; dmarc=none X-Rspam-User: X-Rspamd-Server: rspam09 X-HE-Tag: 1663010801-663506 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: On Mon, 12 Sep 2022 22:39:03 +0800 Dawei Li wrote: > Kdamond is implemented as a periodical split-merge pattern, which will > create and destroy regions possibly on high frequency(hundreds or even > thousands of per sec), depending on number of regions and aggregation > period. In that case, kmalloc and kfree could bring considerable overhead > to system, which can be improved by private kmem cache. > A dedicated slab cache should be faster and will also consume less memory, due to better packing into the underlying pages. So I redid the changelog thusly: : Kdamond is implemented as a periodical split-merge pattern, which will : create and destroy regions possibly at high frequency (hundreds or even : thousands of per sec), depending on the number of regions and aggregation : period. In that case, kmalloc and kfree could bring speed and space : overheads, which can be improved by using a private kmem cache. > +static int __init damon_init(void) > +{ > + damon_region_cache = kmem_cache_create("damon_region_cache", sizeof(struct damon_region), Should be able to use just damon_region_cache = KMEM_CACHE(damon_region, 0); here. Please test that and send along a fixup patch?