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 X-Spam-Level: X-Spam-Status: No, score=-22.4 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8BF3DC432BE for ; Fri, 30 Jul 2021 14:06:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 1034860F36 for ; Fri, 30 Jul 2021 14:06:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 1034860F36 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9318B8D0002; Fri, 30 Jul 2021 10:06:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8E1958D0001; Fri, 30 Jul 2021 10:06:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7D00E8D0002; Fri, 30 Jul 2021 10:06:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0111.hostedemail.com [216.40.44.111]) by kanga.kvack.org (Postfix) with ESMTP id 605058D0001 for ; Fri, 30 Jul 2021 10:06:05 -0400 (EDT) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 0F2AB8249980 for ; Fri, 30 Jul 2021 14:06:05 +0000 (UTC) X-FDA: 78419428290.11.D52BCD5 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by imf30.hostedemail.com (Postfix) with ESMTP id 682FEE003971 for ; Fri, 30 Jul 2021 14:06:04 +0000 (UTC) Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 E50312243D; Fri, 30 Jul 2021 14:06:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1627653962; h=from:from:reply-to: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; bh=k7WY6osdL3kzI8WtGYidMekSaPQZMy3NpPkiI7bG8dY=; b=DvPL+4qdhYPN3m8/xO29owC86+WH1MZxRIdjXnDau8Tx+VsKzchVkk0XFggymADiyXn9Vj IbD970moLckZVqjMloQoWC2IT0N3kuJ5Z/nYu75gAEt7Bstu0ABkRCzGiLRxVX37OU/5Ro /bH7SECXmn3TXdStTj6KWOomhCfLDkY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1627653962; h=from:from:reply-to: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; bh=k7WY6osdL3kzI8WtGYidMekSaPQZMy3NpPkiI7bG8dY=; b=8dUpkk4qTOr4/g8jHJS9wDAN9YuEpx+IOce2e55yDsmmcYZDEpJcSIpBxzDR52dpLqrGcV W25TcRYwCgCL+PDA== Received: from imap1.suse-dmz.suse.de (imap1.suse-dmz.suse.de [192.168.254.73]) (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 imap1.suse-dmz.suse.de (Postfix) with ESMTPS id A8F2F13806; Fri, 30 Jul 2021 14:06:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap1.suse-dmz.suse.de with ESMTPSA id 3smNKEoHBGEocgAAGKfGzw (envelope-from ); Fri, 30 Jul 2021 14:06:02 +0000 Subject: Re: [PATCH V5] mm: compaction: support triggering of proactive compaction by user To: Charan Teja Reddy , akpm@linux-foundation.org, mcgrof@kernel.org, keescook@chromium.org, yzaikin@google.com, dave.hansen@linux.intel.com, mgorman@techsingularity.net, nigupta@nvidia.com, corbet@lwn.net, rppt@kernel.org, khalid.aziz@oracle.com, rientjes@google.com Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, vinmenon@codeaurora.org References: <1627653207-12317-1-git-send-email-charante@codeaurora.org> From: Vlastimil Babka Message-ID: <8fe4ba65-28e1-02d8-cf4d-74aaa76fe9df@suse.cz> Date: Fri, 30 Jul 2021 16:06:02 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <1627653207-12317-1-git-send-email-charante@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 682FEE003971 Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=DvPL+4qd; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=8dUpkk4q; dmarc=none; spf=pass (imf30.hostedemail.com: domain of vbabka@suse.cz designates 195.135.220.28 as permitted sender) smtp.mailfrom=vbabka@suse.cz X-Stat-Signature: prxskw3huffj5xnd7xs8zcgm8n7oadoj X-HE-Tag: 1627653964-820062 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 7/30/21 3:53 PM, Charan Teja Reddy wrote: > The proactive compaction[1] gets triggered for every 500msec and run > compaction on the node for COMPACTION_HPAGE_ORDER (usually order-9) > pages based on the value set to sysctl.compaction_proactiveness. > Triggering the compaction for every 500msec in search of > COMPACTION_HPAGE_ORDER pages is not needed for all applications, > especially on the embedded system usecases which may have few MB's of > RAM. Enabling the proactive compaction in its state will endup in > running almost always on such systems. > > Other side, proactive compaction can still be very much useful for > getting a set of higher order pages in some controllable > manner(controlled by using the sysctl.compaction_proactiveness). So, on > systems where enabling the proactive compaction always may proove not > required, can trigger the same from user space on write to its sysctl > interface. As an example, say app launcher decide to launch the memory > heavy application which can be launched fast if it gets more higher > order pages thus launcher can prepare the system in advance by > triggering the proactive compaction from userspace. > > This triggering of proactive compaction is done on a write to > sysctl.compaction_proactiveness by user. > > [1]https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit?id=facdaa917c4d5a376d09d25865f5a863f906234a > > Signed-off-by: Charan Teja Reddy Acked-by: Vlastimil Babka > @@ -2895,9 +2920,16 @@ static int kcompactd(void *p) > while (!kthread_should_stop()) { > unsigned long pflags; > > + /* > + * Avoid the unnecessary wakeup for proactive compaction > + * when it is disabled. > + */ > + if (!sysctl_compaction_proactiveness) > + timeout = MAX_SCHEDULE_TIMEOUT; Does this part actually logically belong more to your previous patch that optimized the deferred timeouts? > trace_mm_compaction_kcompactd_sleep(pgdat->node_id); > if (wait_event_freezable_timeout(pgdat->kcompactd_wait, > - kcompactd_work_requested(pgdat), timeout)) { > + kcompactd_work_requested(pgdat), timeout) && > + !pgdat->proactive_compact_trigger) { > > psi_memstall_enter(&pflags); > kcompactd_do_work(pgdat); > @@ -2932,6 +2964,8 @@ static int kcompactd(void *p) > timeout = > default_timeout << COMPACT_MAX_DEFER_SHIFT; > } > + if (unlikely(pgdat->proactive_compact_trigger)) > + pgdat->proactive_compact_trigger = false; > } > > return 0; >