Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp2368359rwp; Fri, 14 Jul 2023 05:17:23 -0700 (PDT) X-Google-Smtp-Source: APBJJlF23wo2witl2pB+3N1SHFxWHK7wrzSu2FaJCdVNqzccxfLEpaOuvES2paeXLIQhDjCTHrhZ X-Received: by 2002:a05:6a00:849:b0:680:d00c:b164 with SMTP id q9-20020a056a00084900b00680d00cb164mr6053916pfk.34.1689337043672; Fri, 14 Jul 2023 05:17:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689337043; cv=none; d=google.com; s=arc-20160816; b=MCGj1oH/VhsTBLuQrp9IEsk0PZL84bu08XyKesWhdD3T3BY5KqpwJ7M1LjNlTZAIHm arvBIKRp9k593rGXaVM0O0Oek4CdySfLZhTjzqNWSooDPbda80cZvh2jUnBaomkkSxqP aXsaaDvRCmI7wZXUt63NXqvEmRLz06QTp/7qzR/jjB7DaUX6ifo+c8SA57aMpnVRuHpg OCTZIlOKrv/mZSULXWCqogGOgmuWZwlOwRaVfAdaSqijMNw3xbPjCTHrt+OSn7tA0a+1 I0zj6DeBwyGdbg/FcRwEW6/V1MQwj7octQneMdZdAJ9tf9kRQkjNRGL6dWpXInE4e5Oi 5xXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iilSheHIUhgnsn15zN9O4xrXzcgpGmmRPakgPtr45AM=; fh=NHMpLrzysEZmJGUQxACDELga68toCL+EhFM7C7CImdI=; b=y86O4eNGEhcW3aJ6XzH5PcdTu7dA4zQWIhriaZty6WDTHV4Tg+S/zNS+CcKjOUYo7/ XDHNxLX7HlDqixM0MZ0vOS9CHkKXWj3WPKHNrX+oqrqmWIz4ZflLl8iS0y8QCA3HP85W /5ach3H/jsCpbnyX2cWgDholf0sO+IpaflSyBmBD/OfFwZPq98JPvf5ZqJcsV1zYjb3V y85tu5pbkXfz3r1xh09Mg5sZHSBQfQFutiulCLMOlUI+JN/i3E55FSmEKIrceIK9MKwQ sfi81ljCRt1wWRQQNOhJKyhcxT9u63FkjH7vRYsMu5Zd9bB5uRWFD6LxJV8WLuYKdM9+ 7uZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=XQo5MHIA; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a056a00189000b006789229c538si7139159pfh.48.2023.07.14.05.17.11; Fri, 14 Jul 2023 05:17:23 -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=@suse.com header.s=susede1 header.b=XQo5MHIA; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235303AbjGNLmb (ORCPT + 99 others); Fri, 14 Jul 2023 07:42:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44932 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234567AbjGNLm2 (ORCPT ); Fri, 14 Jul 2023 07:42:28 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8627535B3 for ; Fri, 14 Jul 2023 04:41:58 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 00ADA2209F; Fri, 14 Jul 2023 11:41:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1689334890; h=from:from:reply-to: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=iilSheHIUhgnsn15zN9O4xrXzcgpGmmRPakgPtr45AM=; b=XQo5MHIA02k7FaZ/QWVO6OpYvFpMXlPWusvgWQ6WpC3IdDJEGdWpcJkM/nwl/8we72XFfn Z5QLr1PW+J58HRL0qHho+YJUudt5t25D5W8L8XaWxuG4iQuhm76O/EDDoBjLEO38ArXIUI pG7wRONnYxbgMTQrMgxR97oqYr79nFo= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D588F138F8; Fri, 14 Jul 2023 11:41:29 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Gbf1MWk0sWTdOQAAMHmgww (envelope-from ); Fri, 14 Jul 2023 11:41:29 +0000 Date: Fri, 14 Jul 2023 13:41:28 +0200 From: Michal Hocko To: Mel Gorman Cc: Huang Ying , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Arjan Van De Ven , Andrew Morton , Vlastimil Babka , David Hildenbrand , Johannes Weiner , Dave Hansen , Pavel Tatashin , Matthew Wilcox Subject: Re: [RFC 2/2] mm: alloc/free depth based PCP high auto-tuning Message-ID: References: <20230710065325.290366-1-ying.huang@intel.com> <20230710065325.290366-3-ying.huang@intel.com> <20230712090526.thk2l7sbdcdsllfi@techsingularity.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230712090526.thk2l7sbdcdsllfi@techsingularity.net> X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_PASS, T_SCC_BODY_TEXT_LINE,T_SPF_HELO_TEMPERROR,URIBL_BLOCKED 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 Wed 12-07-23 10:05:26, Mel Gorman wrote: > On Tue, Jul 11, 2023 at 01:19:46PM +0200, Michal Hocko wrote: > > On Mon 10-07-23 14:53:25, Huang Ying wrote: > > > To auto-tune PCP high for each CPU automatically, an > > > allocation/freeing depth based PCP high auto-tuning algorithm is > > > implemented in this patch. > > > > > > The basic idea behind the algorithm is to detect the repetitive > > > allocation and freeing pattern with short enough period (about 1 > > > second). The period needs to be short to respond to allocation and > > > freeing pattern changes quickly and control the memory wasted by > > > unnecessary caching. > > > > 1s is an ethernity from the allocation POV. Is a time based sampling > > really a good choice? I would have expected a natural allocation/freeing > > feedback mechanism. I.e. double the batch size when the batch is > > consumed and it requires to be refilled and shrink it under memory > > pressure (GFP_NOWAIT allocation fails) or when the surplus grows too > > high over batch (e.g. twice as much). Have you considered something as > > simple as that? > > Quite honestly I am not sure time based approach is a good choice > > because memory consumptions tends to be quite bulky (e.g. application > > starts or workload transitions based on requests). > > > > I tend to agree. Tuning based on the recent allocation pattern without frees > would make more sense and also be symmetric with how free_factor works. I > suspect that time-based may be heavily orientated around the will-it-scale > benchmark. While I only glanced at this, a few things jumped out > > 1. Time-based heuristics are not ideal. congestion_wait() and > friends was an obvious case where time-based heuristics fell apart even > before the event it waited on was removed. For congestion, it happened to > work for slow storage for a while but that was about it. For allocation > stream detection, it has a similar problem. If a process is allocating > heavily, then fine, if it's in bursts of less than a second more than one > second apart then it will not adapt. While I do not think it is explicitly > mentioned anywhere, my understanding was that heuristics like this within > mm/ should be driven by explicit events as much as possible and not time. Agreed. I would also like to point out that it is also important to realize those events that we should care about. Remember the primary motivation of the tuning is to reduce the lock contention. That being said, it is less of a problem to have stream or bursty demand for memory if that doesn't really cause the said contention, right? So any auto-tuning should consider that as well and do not inflate the batch in an absense of the contention. That of course means that a solely deallocation based monitoring. -- Michal Hocko SUSE Labs