Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp5671092rwn; Mon, 12 Sep 2022 12:32:40 -0700 (PDT) X-Google-Smtp-Source: AA6agR7usHwptotbbl8oVQ/uU7lZYxrUwxYsNxhycqeCcP3oe11kq9/4/0YnZ/+4RX1T504LUZly X-Received: by 2002:a62:1a8d:0:b0:544:1309:19f3 with SMTP id a135-20020a621a8d000000b00544130919f3mr5556677pfa.37.1663011159888; Mon, 12 Sep 2022 12:32:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663011159; cv=none; d=google.com; s=arc-20160816; b=sO7hXRmPkZZEEJSE+vjXw5cZVjTNnwJh1R4ttcYuBJA8Mt3Cium+9nXUw+nMGkDABs amDLgrdRNd+l46mPZtUcXfY5WMpbbowsLAwZeL/uc/V2oxH9rfaoVIr1dHXv14I+NgZE WV7XFxSbrxaymRlBYRCkZVoIDVRRzs+J9qhYZjEgqLeHOn3Mu5mL+IXk0kUhJNJhDFCc D48o7Kof+wesW5Wz/Im9LnM7HMjoYLh4zOJ/hSCWfq5XbB+3YVW/3J5WJoGpdNy1tWUF EQGPIGzW7ZS7XZk48iLk2uBYi5pRVTCOGdWJ5Ar4NrQprpjprydlthbmzlB3SGiXURoB iu6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=h6Xpae1eyuUQ7qEP3C3e63RYP90pweoOIS65qi40OsQ=; b=XJn/zBy23c9a/NuPegT/4ecS1wEJ5Fl3m9fGSNdfjmuEhhbleWnoGPQG7F2bH+lhXR CVF8fEN0e+fkXjoBIxB5LB77S/hgdQQ9ax5wjudxRGa27Riev+6f6JNgU4Bwu0a1Vets F86nRT5NpoIOGHFbd9AZl5AsI9O3y2xhuKzYrpvbdW5iaOBsWir2FS1uLZOHDth99jGc xPsjpBKpW32WgBUm0RmLsQ7UjtRu5ULLBHccxXl45UwP9azx57TfoDACWhI35Q9fag47 eeqHcquJbqjRzbpBkep6pwZXYghdF4zeLYGlLSbGhuU/Yja+h2TlCh86JXqpMXPWkBUi ESRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=S1Dkyxk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o12-20020a655bcc000000b00434b5c7ddcasi10262060pgr.640.2022.09.12.12.32.28; Mon, 12 Sep 2022 12:32:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=S1Dkyxk4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229677AbiILT0p (ORCPT + 99 others); Mon, 12 Sep 2022 15:26:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229650AbiILT0n (ORCPT ); Mon, 12 Sep 2022 15:26:43 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0860312608 for ; Mon, 12 Sep 2022 12:26:42 -0700 (PDT) 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 ams.source.kernel.org (Postfix) with ESMTPS id AA1B6B80DBF for ; Mon, 12 Sep 2022 19:26:41 +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 X-Spam-Status: No, score=-9.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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?