Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2216590pxk; Mon, 14 Sep 2020 07:37:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz0VOaHUhUmnz7YI2ke/MoXJO8gXjsQ73ZlR6CH5L0jjyIO5yTk4Jc9d+4NuNmzCnaqHeT0 X-Received: by 2002:a17:906:556:: with SMTP id k22mr14691732eja.369.1600094244771; Mon, 14 Sep 2020 07:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600094244; cv=none; d=google.com; s=arc-20160816; b=Xn94ATB+IIxqdO8OEri5UxAaU+NXKWwjrUJRtqV9CM8ovWxCx66ESAsSYm0YJE6Lct pK1q9DjiBWiCCSuhC5DZb1pXzIFCfrB9/7ml5Gt8Bh4DqbSxOfjB24BIu0/joP+YeIyS gUvRL38IEiBPgviP80IEcuLYIcvNe2xwCvx2r3cTv2dHmQw/DIsLyqvQOWKY2XwlrYm7 bgLkueSo+h9Lm+rDzb3THphJ0vYShZwGo1l8Xuj39LAb6uB8ei0meOK6cXTatOEvouZU hLNSuwXS5OiRi9WByc+cznwYa2VT+mUisNwQ9cHkHrFeA1KmIJ1pmX+474bb63NIthtt 4RDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=AEV2BYvGf4jUKby6y/yqA8EH2+uCWeDeQ+CmCMN+d6Q=; b=pFi7AqJVcvDLm4qKglk5JXxwJb3Gqh8H5hXdv0litcXlvTExgGVDdo1HubGcNPMGHL 7jz+Y1D1LERcpBBKs2RfNvAdGfyVs62ObesyrDqTnWd66gCUg3Y3HPvbmhr2QonEK+Hw Msknj/S82h5EtI2oc9RhgnEYzZjpjSwFwg2aB10X6zPKARjWXOViopBx5H+S6Q3PCLKQ ZYlQF+FqC0nJVmTo4dsr41sKzZQuUM6JGkmVBXb6CAa58LlxtoLNmuM/Ibecv1jimdif KkaCjHO8+OW7zYLMs7wv2bxTnhSjLqVNtUCw96wJ98qBOJuGcGw1Y7emxVHQoNDFJ6Jb t8bg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l5si7052540ejd.109.2020.09.14.07.37.03; Mon, 14 Sep 2020 07:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726697AbgINOed (ORCPT + 99 others); Mon, 14 Sep 2020 10:34:33 -0400 Received: from mx2.suse.de ([195.135.220.15]:39496 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbgINOdQ (ORCPT ); Mon, 14 Sep 2020 10:33:16 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id CF793B3C9; Mon, 14 Sep 2020 14:33:27 +0000 (UTC) Date: Mon, 14 Sep 2020 16:33:12 +0200 From: Michal Hocko To: Vijay Balakrishna Cc: Andrew Morton , "Kirill A. Shutemov" , Oleg Nesterov , Song Liu , Andrea Arcangeli , Pavel Tatashin , Allen Pais , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [[PATCH]] mm: khugepaged: recalculate min_free_kbytes after memory hotplug as expected by khugepaged Message-ID: <20200914143312.GU16999@dhcp22.suse.cz> References: <1599770859-14826-1-git-send-email-vijayb@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1599770859-14826-1-git-send-email-vijayb@linux.microsoft.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu 10-09-20 13:47:39, Vijay Balakrishna wrote: > When memory is hotplug added or removed the min_free_kbytes must be > recalculated based on what is expected by khugepaged. Currently > after hotplug, min_free_kbytes will be set to a lower default and higher > default set when THP enabled is lost. This leaves the system with small > min_free_kbytes which isn't suitable for systems especially with network > intensive loads. Typical failure symptoms include HW WATCHDOG reset, > soft lockup hang notices, NETDEVICE WATCHDOG timeouts, and OOM process > kills. Care to explain some more please? The whole point of increasing min_free_kbytes for THP is to get a larger free memory with a hope that huge pages will be more likely to appear. While this might help for other users that need a high order pages it is definitely not the primary reason behind it. Could you provide an example with some more data? I do see how the inconsistency between boot and hotplug watermarks setting is not ideal but I do worry about interaction with the user specific values as a potential problem. set_recommended_min_free_kbytes happens early enough that user space cannot really interfere but the hotplug happens at any time. > Fixes: f000565adb77 ("thp: set recommended min free kbytes") > > Signed-off-by: Vijay Balakrishna > Cc: stable@vger.kernel.org > --- > include/linux/khugepaged.h | 5 +++++ > mm/khugepaged.c | 13 +++++++++++-- > mm/memory_hotplug.c | 3 +++ > 3 files changed, 19 insertions(+), 2 deletions(-) > > diff --git a/include/linux/khugepaged.h b/include/linux/khugepaged.h > index bc45ea1efbf7..c941b7377321 100644 > --- a/include/linux/khugepaged.h > +++ b/include/linux/khugepaged.h > @@ -15,6 +15,7 @@ extern int __khugepaged_enter(struct mm_struct *mm); > extern void __khugepaged_exit(struct mm_struct *mm); > extern int khugepaged_enter_vma_merge(struct vm_area_struct *vma, > unsigned long vm_flags); > +extern void khugepaged_min_free_kbytes_update(void); > #ifdef CONFIG_SHMEM > extern void collapse_pte_mapped_thp(struct mm_struct *mm, unsigned long addr); > #else > @@ -85,6 +86,10 @@ static inline void collapse_pte_mapped_thp(struct mm_struct *mm, > unsigned long addr) > { > } > + > +static inline void khugepaged_min_free_kbytes_update(void) > +{ > +} > #endif /* CONFIG_TRANSPARENT_HUGEPAGE */ > > #endif /* _LINUX_KHUGEPAGED_H */ > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index cfa0dba5fd3b..4f7107476a6f 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -56,6 +56,9 @@ enum scan_result { > #define CREATE_TRACE_POINTS > #include > > +static struct task_struct *khugepaged_thread __read_mostly; > +static DEFINE_MUTEX(khugepaged_mutex); > + > /* default scan 8*512 pte (or vmas) every 30 second */ > static unsigned int khugepaged_pages_to_scan __read_mostly; > static unsigned int khugepaged_pages_collapsed; > @@ -2292,8 +2295,6 @@ static void set_recommended_min_free_kbytes(void) > > int start_stop_khugepaged(void) > { > - static struct task_struct *khugepaged_thread __read_mostly; > - static DEFINE_MUTEX(khugepaged_mutex); > int err = 0; > > mutex_lock(&khugepaged_mutex); > @@ -2320,3 +2321,11 @@ int start_stop_khugepaged(void) > mutex_unlock(&khugepaged_mutex); > return err; > } > + > +void khugepaged_min_free_kbytes_update(void) > +{ > + mutex_lock(&khugepaged_mutex); > + if (khugepaged_enabled() && khugepaged_thread) > + set_recommended_min_free_kbytes(); > + mutex_unlock(&khugepaged_mutex); > +} > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c > index e9d5ab5d3ca0..3e19272c1fad 100644 > --- a/mm/memory_hotplug.c > +++ b/mm/memory_hotplug.c > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > > #include > > @@ -857,6 +858,7 @@ int __ref online_pages(unsigned long pfn, unsigned long nr_pages, > zone_pcp_update(zone); > > init_per_zone_wmark_min(); > + khugepaged_min_free_kbytes_update(); > > kswapd_run(nid); > kcompactd_run(nid); > @@ -1600,6 +1602,7 @@ static int __ref __offline_pages(unsigned long start_pfn, > pgdat_resize_unlock(zone->zone_pgdat, &flags); > > init_per_zone_wmark_min(); > + khugepaged_min_free_kbytes_update(); > > if (!populated_zone(zone)) { > zone_pcp_reset(zone); > -- > 2.28.0 > -- Michal Hocko SUSE Labs