Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp803685ybk; Wed, 13 May 2020 13:35:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwSDRzdRC3U7sGqSlS0GElkDrFzwPdXGCdxfsax9cAfcfblB2rJpNz9TEclgscBYM2UW9yJ X-Received: by 2002:a17:906:ce36:: with SMTP id sd22mr839782ejb.94.1589402103917; Wed, 13 May 2020 13:35:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589402103; cv=none; d=google.com; s=arc-20160816; b=IRnQqfww6g8XgTe/+IINlBJeJR1LecJTPWchEmTG5C9+CYh6reV34o749JSEva5b7k oJ6u/VUPJGr0dcsSW+o/5EjsI5pxYJSe5B3XZXZiYt2qnfiCba49qlDB0bh9Z719UGPh dRw8WsgTPM9Ye9y0HBL+QoGm3QXkugsbqG86vUjzsYwb5PB361VzG19/fIh/cOA3lsyN xJ++fGnesjiPowH3a8xKcLmQ0dYn6PIx5Q7rpNqEFopK+iYs2SBQWp8hzE29MwfwRa8U 9J0aYqTvS1JnQ/KimpoN7SzNdll99pel4cl9IJqvKPWKJcEiRysxv8uHidvckBx408i+ yICg== 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:references:cc:to:from:subject:dmarc-filter :dkim-signature; bh=2ym0u7X5Osc4xDJAmwudyg1fVc6L2CkIAndFTTBUaJY=; b=KI090JqMIZkTwYbWzSwU03F+NJ6zTaU9+0VsJwakvPFVtGlJ+JTTb+NonjMssXghnl +FVLBBxtqfQKlbq7dmr3g9rMQDkDhEl8MUttYrQenDC1RWyU/EfqE9s0UQ/qSAkT/mBs aOQBT31IdMnkAfRIoYl2Nmy/Sv4b760h4KyoSi1eGyAy5m41bCmar/ELX8XTbieP//Zf Ge/j4vPQp1cIibAB7k4mKmHr8w+TrSe06JUkZVY9S8yjBmUF859yxGAZZsCrz48zH4uP jnO63WEwHWZ8RgkNSiROAAwVAK9HGJCmFJ3L2PLS4S9wXzAASzarp/ozSOhDBINKVyJq PBlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ekdaiBxL; 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 k10si396494eds.461.2020.05.13.13.34.40; Wed, 13 May 2020 13:35:03 -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; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=ekdaiBxL; 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 S2388712AbgEMKFA (ORCPT + 99 others); Wed, 13 May 2020 06:05:00 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:15134 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732794AbgEMJrO (ORCPT ); Wed, 13 May 2020 05:47:14 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1589363233; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: References: Cc: To: From: Subject: Sender; bh=2ym0u7X5Osc4xDJAmwudyg1fVc6L2CkIAndFTTBUaJY=; b=ekdaiBxLIn+3knPeZldLX1TCfs+v9TmsmihdDGEk85NO/PpNEZ438qU2Elh62KoxP8syqOaX VyS05N9uZ9upo/2bggVaI8CwFnQDcqYUI8dqXLyEbMjPm6mD1dZwET9P2u/JMmoylkXF0FuW 9gxZQ5i0Up6E4WlPq8l5o+oUxmI= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5ebbc214.7fa93407ea78-smtp-out-n02; Wed, 13 May 2020 09:47:00 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 8D8A8C433BA; Wed, 13 May 2020 09:46:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.0.102] (unknown [183.83.139.238]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: charante) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3ABCEC432C2; Wed, 13 May 2020 09:46:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3ABCEC432C2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=charante@codeaurora.org Subject: Re: [PATCH] mm, page_alloc: reset the zone->watermark_boost early From: Charan Teja Kalla To: Andrew Morton Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, vinmenon@codeaurora.org References: <1589204408-5152-1-git-send-email-charante@codeaurora.org> <20200511131155.0b40ee443c3367e8f748b16f@linux-foundation.org> <1cf5e778-eae1-fc71-aed4-d84d664d79dd@codeaurora.org> Message-ID: Date: Wed, 13 May 2020 15:16:53 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <1cf5e778-eae1-fc71-aed4-d84d664d79dd@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/12/2020 7:01 PM, Charan Teja Kalla wrote: > > Thank you Andrew for the reply. > > On 5/12/2020 1:41 AM, Andrew Morton wrote: >> On Mon, 11 May 2020 19:10:08 +0530 Charan Teja Reddy wrote: >> >>> Updating the zone watermarks by any means, like extra_free_kbytes, >>> min_free_kbytes, water_mark_scale_factor e.t.c, when watermark_boost is >>> set will result into the higher low and high watermarks than the user >>> asks. This can be avoided by resetting the zone->watermark_boost to zero >>> early. >> >> Does this solve some problem which has been observed in testing? Sorry that I misunderstood your question. Yes it has solved problem of higher water marks seen in the zone than what I set through min_free_kbytes. Below are the steps I pursued to reproduce the problem 1) My system setup of Android kernel running on snapdragon hardware have the below settings as default: #cat /proc/sys/vm/min_free_kbytes = 5162 #cat /proc/zoneinfo | grep -e boost -e low -e "high " -e min -e Node Node 0, zone Normal min 797 low 8340 high 8539 boost 0 // This is the extra print I have added to check the boosting 2) Now I just try to change the zone watermark when the ->watermark_boost is greater than zero. I just write the same value of min_free_kbytes in which case we should have seen the watermarks same as default(I mean of step 1) #echo 5162 > /proc/sys/vm/min_free_kbytes But I have seen very high values of watermarks in the system, # cat /proc/zoneinfo | grep -e boost -e low -e "high " -e min -e Node Node 0, zone Normal min 797 low 21148 high 21347 boost 0 So, yes, this problem is got fixed with the changes made in this patch. > > Sorry, what are those issues observed in testing? It would be helpful > If you post them here. > >> >>> ... >>> >>> --- a/mm/page_alloc.c >>> +++ b/mm/page_alloc.c >>> @@ -7746,9 +7746,9 @@ static void __setup_per_zone_wmarks(void) >>> mult_frac(zone_managed_pages(zone), >>> watermark_scale_factor, 10000)); >>> >>> + zone->watermark_boost = 0; >>> zone->_watermark[WMARK_LOW] = min_wmark_pages(zone) + tmp; >>> zone->_watermark[WMARK_HIGH] = min_wmark_pages(zone) + tmp * 2; >>> - zone->watermark_boost = 0; >>> >>> spin_unlock_irqrestore(&zone->lock, flags); >>> } >> >> This could only be a problem if code is accessing these things without >> holding zone->lock. Is that ever the case? >> > > This is a problem even when accessing these things with zone->lock > held because we are directly using the macro min_wmark_pages(zone) > which leads to the issue. Pasting macro here for reference. > > #define min_wmark_pages(z) (z->_watermark[WMARK_MIN] + z->watermark_boost) > > Steps that lead to the issue is like below: > 1) On the extfrag event, we try to boost the watermark by storing the > value in ->watermark_boost. > > 2) User changes the value of extra|min_free_kbytes or watermark_scale_factor. > > In __setup_perzone_wmarks, we directly store the user asked > watermarks in the zones structure. In this step, the value > is always offsets by ->watermark_boost as we use the min_wmark_pages() macro. > > 3) Later, when kswapd woke up, it resets the zone's watermark_boost to zero. > > Step 2 from the above is what resulting into the issue. > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project