Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp69708ybv; Tue, 4 Feb 2020 16:36:49 -0800 (PST) X-Google-Smtp-Source: APXvYqwZUkHGbPdIcm7icBWVSCQz3Yol2YupPEcL7FXkIddBGmxWTKNcWPF1OlIdReVMdrnprhNy X-Received: by 2002:aca:5f87:: with SMTP id t129mr1244004oib.36.1580863009134; Tue, 04 Feb 2020 16:36:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1580863009; cv=none; d=google.com; s=arc-20160816; b=T3IS1axGZZ48CSz8l802QW4vnEPXxYJkjurskYa+PMGEb3vu4wozYvrY/AW2CWxcxy 2CEVmfD5E7XlA69FiQT14Nd/JvFmG01/IaHjDXSHOQ+zaC92pAuR+ESKKxtA/pitCiT3 FiTe5PSClHQZejwQhaaY6SdqZ1cwI3+cn4rTtVOrtMVhIVU82oU63BlSR52/HY2QtRAP LrXZpS0ZhVE2LWbFahe1E/DcUfzH6oEQFPIQY6Wwj18bNKT1YFot2/o1aLxdc0TBX7SA rzNioEztiqcfMlchUIEc/Uq7sUy+rc6F/me1kgFMG57UGFLvKBAFatNKqngXt77MQui6 bE0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=kGOQ7NHx5iGyKYpiBgXur9/H4UicNxrTxCUlBQ+Qh6M=; b=sN7M7Y/b9/T/8wKcjX0MnTFDINtIx8zI/iCpohCCd0duSTbG1CR9Q7cwJMCfzuO2UF 06/A2j1qIgVdQgLF0Uy9Z8xsWtbS3IGVLhRxlLzbRsj0Px5G30zcLsMWeemqv5jjl5Zo +5AfYbnaKXt2g2i+0LXZnp9lAT7HN5KuwSRqcg1gcMChgewQMhnOL1GAndNl7TpLYebg jNM3aNJXqDbJKPXdnBCK1jrYtGEZp5OPakgBNduFrZP87DW1hjNOuWc3f41xLxIK/3j1 33+jE5c6+RB4lfjaxaSOJcSvwnbCk+WExPElS0WepK8y2rhgNx4z5fko/3apcsNAh6pg mlqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=jPuuL8HZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l83si11360152oih.58.2020.02.04.16.36.36; Tue, 04 Feb 2020 16:36:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=jPuuL8HZ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727674AbgBEAfN (ORCPT + 99 others); Tue, 4 Feb 2020 19:35:13 -0500 Received: from userp2120.oracle.com ([156.151.31.85]:37676 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727494AbgBEAfN (ORCPT ); Tue, 4 Feb 2020 19:35:13 -0500 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150XHhc108952; Wed, 5 Feb 2020 00:34:43 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=corp-2019-08-05; bh=kGOQ7NHx5iGyKYpiBgXur9/H4UicNxrTxCUlBQ+Qh6M=; b=jPuuL8HZrmAKrURhg44aIRjLWSTWAqBdNgn9vwUDRORuyBShty7i6//C53vdJ127l9Zh sx/CUEvnF4PcRt6xXROKLLs5t1ARlDaK6n7afxud/CW8AZcM46/dxWI1tEJ4GqoMzQts ty1G1LhaeqrXFF4Sg09FCla+ZHu8MOdFVVSiRaTiFA2eLBU0YwpqIv3KARnR1LhjMN26 4S56Ey+P5ww3cEFL+SvtbuSEUGiBC/KQTVP+10+K5eV36jnqDHDTzUxsDmcs6SYEMK1f aW3g+Amrp6UiT5cdA7QSGmxHZ7DCeY2yrL0vqfYII2EiPjuf6is/MQq8s2rIZwUTgLXA kA== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2xyhkf8b2h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:34:43 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id 0150YcUp115308; Wed, 5 Feb 2020 00:34:42 GMT Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userp3020.oracle.com with ESMTP id 2xyhmqxv67-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 05 Feb 2020 00:34:42 +0000 Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id 0150XT2S005360; Wed, 5 Feb 2020 00:33:29 GMT Received: from [192.168.1.206] (/71.63.128.209) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 04 Feb 2020 16:33:28 -0800 Subject: Re: [PATCH] mm: always consider THP when adjusting min_free_kbytes To: Matthew Wilcox Cc: David Rientjes , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Song Liu , "Kirill A.Shutemov" , Mel Gorman , Vlastimil Babka , Andrew Morton References: <20200204194156.61672-1-mike.kravetz@oracle.com> <8cc18928-0b52-7c2e-fbc6-5952eb9b06ab@oracle.com> <20200204215319.GO8731@bombadil.infradead.org> From: Mike Kravetz Message-ID: Date: Tue, 4 Feb 2020 16:33:27 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200204215319.GO8731@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2001150001 definitions=main-2002050001 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9521 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-2001150001 definitions=main-2002050001 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/4/20 1:53 PM, Matthew Wilcox wrote: > On Tue, Feb 04, 2020 at 01:42:43PM -0800, Mike Kravetz wrote: >> On 2/4/20 12:33 PM, David Rientjes wrote: >>> On Tue, 4 Feb 2020, Mike Kravetz wrote: >>> >>> Hmm, if khugepaged_adjust_min_free_kbytes() increases min_free_kbytes for >>> thp, then the user has no ability to override this increase by using >>> vm.min_free_kbytes? >>> >>> IIUC, with this change, it looks like memory hotplug events properly >>> increase min_free_kbytes for thp optimization but also doesn't respect a >>> previous user-defined value? >> >> Good catch. >> >> We should only call khugepaged_adjust_min_free_kbytes from the 'true' >> block of this if statement in init_per_zone_wmark_min. >> >> if (new_min_free_kbytes > user_min_free_kbytes) { >> min_free_kbytes = new_min_free_kbytes; >> if (min_free_kbytes < 128) >> min_free_kbytes = 128; >> if (min_free_kbytes > 65536) >> min_free_kbytes = 65536; >> } else { >> pr_warn("min_free_kbytes is not updated to %d because user defined value %d is preferred\n", >> new_min_free_kbytes, user_min_free_kbytes); >> } >> >> In the existing code, a hotplug event will cause min_free_kbytes to overwrite >> the user defined value if the new value is greater. However, you will get >> the warning message if the user defined value is greater. I am not sure if >> this is the 'desired/expected' behavior? We print a warning if the user value >> takes precedence over our calculated value. However, we do not print a message >> if we overwrite the user defined value. That doesn't seem right! >> >>> So it looks like this is fixing an obvious correctness issue but also now >>> requires users to rewrite the sysctl if they want to decrease the min >>> watermark. >> >> Moving the call to khugepaged_adjust_min_free_kbytes as described above >> would avoid the THP adjustment unless we were going to overwrite the >> user defined value. Now, I am not sure overwriting the user defined value >> as is done today is actually the correct thing to do. >> >> Thoughts? >> Perhaps we should never overwrite a user defined value? > > We should certainly warn if we would have adjusted it, had they not > changed it! Ok, the code above does that today. > I'm reluctant to suggest we do a more complex adjustment of the value > (eg figure out what the adjustment would have been, then apply some > fraction of that adjustment to keep the ratios in proportion) because > we don't really know why they adjusted it. Agree! > OTOH, we should adjust it if the user-set min_free_kbytes is now too > large for the amount of memory now in the machine. Today, we never overwrite a user defined value that is larger than that calculated by the code. However, we will owerwrite a user defined value if the code calculates a larger value. I'm starting to think the best option is to NEVER overwrite a user defined value. -- Mike Kravetz