From patchwork Thu Aug 13 03:51:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Berger X-Patchwork-Id: 11711647 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E879F109B for ; Thu, 13 Aug 2020 03:52:05 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id A7EC020715 for ; Thu, 13 Aug 2020 03:52:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FJ9PHLG0" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7EC020715 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id AE8188D0002; Wed, 12 Aug 2020 23:52:04 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id A72768D0001; Wed, 12 Aug 2020 23:52:04 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 93AE88D0002; Wed, 12 Aug 2020 23:52:04 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0163.hostedemail.com [216.40.44.163]) by kanga.kvack.org (Postfix) with ESMTP id 799648D0001 for ; Wed, 12 Aug 2020 23:52:04 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0F617180AD806 for ; Thu, 13 Aug 2020 03:52:04 +0000 (UTC) X-FDA: 77144172168.13.wool39_291281626ff1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin13.hostedemail.com (Postfix) with ESMTP id CF8C218140B67 for ; Thu, 13 Aug 2020 03:52:03 +0000 (UTC) X-Spam-Summary: 1,0,0,802e8dba84488c44,d41d8cd98f00b204,opendmb@gmail.com,,RULES_HIT:41:355:379:541:800:960:966:973:988:989:1260:1261:1345:1437:1535:1542:1711:1730:1747:1777:1792:2196:2198:2199:2200:2393:2553:2559:2562:2693:2731:2895:2902:2918:3138:3139:3140:3141:3142:3354:3865:3866:3867:3868:3870:3871:3872:3874:4250:4385:5007:6261:6653:7514:7875:7903:8660:9413:10004:11026:11658:11914:12043:12296:12297:12438:12517:12519:12555:12679:12895:13148:13161:13229:13230:14096:14181:14394:14687:14721:21080:21444:21450:21451:21627:21666:21939:21990:30034:30054:30070:30090,0,RBL:209.85.214.195:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.50.0.100;04yrknmn5gtudw4jh7bkdfq8byt7uoc4igjw16646gdmeffnspkee9isod1d6h5.x7th6rncowefx5779c9e3wam4sat6g6x3c668gfqshdoyypcccx68rnz8eeu8f6.6-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: wool39_291281626ff1 X-Filterd-Recvd-Size: 5057 Received: from mail-pl1-f195.google.com (mail-pl1-f195.google.com [209.85.214.195]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Thu, 13 Aug 2020 03:52:03 +0000 (UTC) Received: by mail-pl1-f195.google.com with SMTP id q19so2052765pll.0 for ; Wed, 12 Aug 2020 20:52:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=VA5B9P3jl9Rwei4btklJKhUkayY4KVxIbC/8uysb2Ms=; b=FJ9PHLG0g7f2Maa7cEQaeUtA3Ylx3IdGyk8cYMtQQU+98QK+IT2QqARjp/wBJnclBX gh6+YGAnyaAijFJi1Sa+mALef97sfGBdvrTpPoi1Tx8/fcwx3zDq290YDgbx0QCLIx+Y jGF0U0KLIzHVkBlpJBAd/BG1JF/1W6VfIMxDDa/lbXLKGWIH0+1lHKtpPgOmlAS68sBZ qLoNgZSoLqdoYUfoKHkCGuNi1zx52XhloQWeVTec1kqBA+ao3SrUx63zekVagojb1lj2 Sy6ZYa/hOxGI0tm69Rqv5U/hZFdlQdoZYBCPKmJbHw1blMl9WYcv72/dlef9I24UTDcK tf0w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=VA5B9P3jl9Rwei4btklJKhUkayY4KVxIbC/8uysb2Ms=; b=pWW8pFAI6pHlwlZipSqhwabz3Sv+U8f3ZfbmivLr3cDIpDimt2Berw0BEcrxXiWnL6 DujTaY27Xd1x3QODYvRYUn6bDZqVvwdL8PDsZZbWpcKwQdhzVtRiE/RfLClatvHGmBho vHWW0dPq+KAzxhiLprlFogYFcF1rkelEu6Qggg7WJ3wqHp+nGWwXn6sETKn4hOuOG+Ys YsGJVThSli3iway9EkaErSikkDs79LvDe0XQI4j8HbForvh1+V3HutcINNeg8SWe5l1v LqicrKALNowIfB1aBh7SnAtA2mtZNO/wVR91SxO+Nkvgc44CpMywGCivyMClsLqOHpVi bKQg== X-Gm-Message-State: AOAM530ENkBpEQ3xBp/KUMy+Vet+Cfw1hXdqI63CLfHUgtnrcOaWJWoF 1VJ58wngZK9/SDY+fOeB1ss= X-Google-Smtp-Source: ABdhPJyyBYECo8VpyG+iLLqstmWjZwM/PavaoCFYPLSee0oyVvu3TxY0sHJDPEst5m3pobV1uZahJQ== X-Received: by 2002:a17:902:a50d:: with SMTP id s13mr2239283plq.135.1597290722526; Wed, 12 Aug 2020 20:52:02 -0700 (PDT) Received: from stbirv-lnx-3.igp.broadcom.net ([192.19.223.252]) by smtp.gmail.com with ESMTPSA id e7sm3630443pgn.64.2020.08.12.20.51.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Aug 2020 20:52:01 -0700 (PDT) From: Doug Berger To: Andrew Morton Cc: Jason Baron , David Rientjes , "Kirill A. Shutemov" , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Doug Berger Subject: [PATCH] mm: include CMA pages in lowmem_reserve at boot Date: Wed, 12 Aug 2020 20:51:38 -0700 Message-Id: <1597290698-24266-1-git-send-email-opendmb@gmail.com> X-Mailer: git-send-email 2.7.4 X-Rspamd-Queue-Id: CF8C218140B67 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam03 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: The lowmem_reserve arrays provide a means of applying pressure against allocations from lower zones that were targeted at higher zones. Its values are a function of the number of pages managed by higher zones and are assigned by a call to the setup_per_zone_lowmem_reserve() function. The function is initially called at boot time by the function init_per_zone_wmark_min() and may be called later by accesses of the /proc/sys/vm/lowmem_reserve_ratio sysctl file. The function init_per_zone_wmark_min() was moved up from a module_init to a core_initcall to resolve a sequencing issue with khugepaged. Unfortunately this created a sequencing issue with CMA page accounting. The CMA pages are added to the managed page count of a zone when cma_init_reserved_areas() is called at boot also as a core_initcall. This makes it uncertain whether the CMA pages will be added to the managed page counts of their zones before or after the call to init_per_zone_wmark_min() as it becomes dependent on link order. With the current link order the pages are added to the managed count after the lowmem_reserve arrays are initialized at boot. This means the lowmem_reserve values at boot may be lower than the values used later if /proc/sys/vm/lowmem_reserve_ratio is accessed even if the ratio values are unchanged. In many cases the difference is not significant, but in others it may have an affect. This commit breaks the link order dependency by invoking init_per_zone_wmark_min() as a postcore_initcall so that the CMA pages have the chance to be properly accounted in their zone(s) and allowing the lowmem_reserve arrays to receive consistent values. Fixes: bc22af74f271 ("mm: update min_free_kbytes from khugepaged after core initialization") Signed-off-by: Doug Berger Acked-by: Michal Hocko