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=-8.0 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, 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 CB86DC433E0 for ; Thu, 11 Jun 2020 08:54:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 49D5E20656 for ; Thu, 11 Jun 2020 08:54:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="Izv3C2Jb" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 49D5E20656 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9D9BE8D008C; Thu, 11 Jun 2020 04:54:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9AFBE8D0084; Thu, 11 Jun 2020 04:54:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84FC58D008C; Thu, 11 Jun 2020 04:54:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0154.hostedemail.com [216.40.44.154]) by kanga.kvack.org (Postfix) with ESMTP id 632068D0084 for ; Thu, 11 Jun 2020 04:54:23 -0400 (EDT) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 180D3180AEF50 for ; Thu, 11 Jun 2020 08:54:23 +0000 (UTC) X-FDA: 76916319606.16.chess75_05085e126dd2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id D09B9100E6939 for ; Thu, 11 Jun 2020 08:54:22 +0000 (UTC) X-HE-Tag: chess75_05085e126dd2 X-Filterd-Recvd-Size: 18492 Received: from mailout2.samsung.com (mailout2.samsung.com [203.254.224.25]) by imf49.hostedemail.com (Postfix) with ESMTP for ; Thu, 11 Jun 2020 08:54:21 +0000 (UTC) Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20200611085418epoutp02cdf59cd2ea0ab96c44171f9244a61094~XcWHR5fuO2386023860epoutp02k for ; Thu, 11 Jun 2020 08:54:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.samsung.com 20200611085418epoutp02cdf59cd2ea0ab96c44171f9244a61094~XcWHR5fuO2386023860epoutp02k DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1591865658; bh=wJGlg6gQGPrYUGotlUQWGrmu/bYVjcK+Ho5qXzqCDgI=; h=Subject:To:Cc:From:Date:In-Reply-To:References:From; b=Izv3C2JbOs3EzQone3MvTTRMOrAjml5JuMyLro2zcNbEj27IYOd/A/xfDycYLk9D7 zCt3IqcXTdhw0xU99xXbVYBYBkDkQHoK25q3Iw4xVV9zZBkP4qDiIS2a6R2WfX6d6c 2bMD8jwJitE8cw20M0UKo94EVNsNyR6t8JKEguUo= Received: from epsnrtp4.localdomain (unknown [182.195.42.165]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20200611085417epcas1p46fe756e9b61a09faca91f8f867bb7cbc~XcWG1gsYB2371223712epcas1p4R; Thu, 11 Jun 2020 08:54:17 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.160]) by epsnrtp4.localdomain (Postfix) with ESMTP id 49jHj42QjwzMqYkb; Thu, 11 Jun 2020 08:54:16 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id 37.75.28578.731F1EE5; Thu, 11 Jun 2020 17:54:15 +0900 (KST) Received: from epsmtrp2.samsung.com (unknown [182.195.40.14]) by epcas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200611085414epcas1p11001e9c0488ca816221e2cbb58ab2371~XcWELarRz0530605306epcas1p1k; Thu, 11 Jun 2020 08:54:14 +0000 (GMT) Received: from epsmgms1p2.samsung.com (unknown [182.195.42.42]) by epsmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200611085414epsmtrp2d8d2587b6ce80b125a4c0b17eaaf07ba~XcWDp_9zb0818408184epsmtrp2f; Thu, 11 Jun 2020 08:54:14 +0000 (GMT) X-AuditID: b6c32a39-8dfff70000006fa2-6f-5ee1f13738a5 Received: from epsmtip2.samsung.com ( [182.195.34.31]) by epsmgms1p2.samsung.com (Symantec Messaging Gateway) with SMTP id 52.8B.08303.631F1EE5; Thu, 11 Jun 2020 17:54:14 +0900 (KST) Received: from [10.253.104.82] (unknown [10.253.104.82]) by epsmtip2.samsung.com (KnoxPortal) with ESMTPA id 20200611085413epsmtip259198e1c1e4e6ec2c97fe7a4eb508a44~XcWCaIzMi0848708487epsmtip2X; Thu, 11 Jun 2020 08:54:12 +0000 (GMT) Subject: Re: [PATCH] page_alloc: consider highatomic reserve in wmartermark fast To: Minchan Kim Cc: mgorman@techsingularity.net, mgorman@suse.de, hannes@cmpxchg.org, akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, jaewon31.kim@gmail.com, ytk.lee@samsung.com, cmlaika.kim@samsung.com From: Jaewon Kim Message-ID: <5EE1F134.4090001@samsung.com> Date: Thu, 11 Jun 2020 17:54:12 +0900 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.7.2 MIME-Version: 1.0 In-Reply-To: <20200610012112.GA239587@google.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJJsWRmVeSWpSXmKPExsWy7bCmrq75x4dxBq9f8lvMWb+GzWLlvHNs Fqs3+Vp0b57JaHF51xw2i3tr/rNaTH73jNFix9J9TBbLvr5nt3i8ntuBy+Pwm/fMHjtn3WX3 2LSqk81j06dJ7B4nZvxm8ejbsorRY/Ppao+tv+w8Pm+SC+CMyrHJSE1MSS1SSM1Lzk/JzEu3 VfIOjneONzUzMNQ1tLQwV1LIS8xNtVVy8QnQdcvMAbpSSaEsMacUKBSQWFyspG9nU5RfWpKq kJFfXGKrlFqQklNgaFCgV5yYW1yal66XnJ9rZWhgYGQKVJmQk/H75022gt6EikddW9gaGL8G dDFyckgImEi0NhxkBrGFBHYwSrR99e1i5AKyPzFKfJvwkQnC+cwosWrBZ3aYjuNPb7NAdOxi lPi9KxOi6C2jxKP+yWBFwgJBEmtuTgcbKyKgIvHn6T9GkCJmgduMEv8vTgZLsAloS7xfMIkV xOYV0JJYMbURqJmDg0VAVWLuUlWQsKhAhMSOuR8ZIUoEJU7OfAK2mFPAUOL9vvdgu5gF5CWa t85mBpkvIbCWQ2LG7xdMIHMkBFwkjl0QhzhaWOLV8S1QD0hJfH63lw3CrpfYs/8vM4TdAHTb RwEI21hifstCZpAxzAKaEut36UOEFSV2/p7LCLGWT+Ld1x5WiE28Eh1tQhAlahItz76yQtgy En//PYOyPSS2Nf+GBvR2RontbwInMCrMQvLYLCTPzEJYvICReRWjWGpBcW56arFhgSly9G5i BKdZLcsdjNPfftA7xMjEwXiIUYKDWUmEV1D8YZwQb0piZVVqUX58UWlOavEhRlNg6E5klhJN zgcm+rySeENTI2NjYwsTM3MzU2MlcV4n6wtxQgLpiSWp2ampBalFMH1MHJxSDUzMOjO/u0n7 Xmb6q2Um7iPz8N0C4Tk8tUnHj3l9nfN0wYqP016pe2V8CipuLWkQuK0uGKVyWO5vBVfTRxHr S7M2nJjfLCpveJLtYtPWsOK9FmFi64P/LtrktiF7NsckeTmDu9lyMqFB8w6e+untwljzY3NT tsw5k8VBvnYfnwT9fqN92fvapkNlh78Z/uiXe2wfb9WU/DU0W/Hvof7UBZOXHetV8arfdPhF ytYVkZwzdUx3pkwKn/39A3spo5r5D2/GEkETs83nPR+WP330fOFvVqO1huJTQ9LYY08rTDXg VNzSa9vs4H7EPHiyVW/TpYR85onOq8oTL/2sZWZJVe7J1+8QZV/m96hv44O7CkosxRmJhlrM RcWJAMKnw8w8BAAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrDLMWRmVeSWpSXmKPExsWy7bCSvK7Zx4dxBo8X81vMWb+GzWLlvHNs Fqs3+Vp0b57JaHF51xw2i3tr/rNaTH73jNFix9J9TBbLvr5nt3i8ntuBy+Pwm/fMHjtn3WX3 2LSqk81j06dJ7B4nZvxm8ejbsorRY/Ppao+tv+w8Pm+SC+CM4rJJSc3JLEst0rdL4Mr4/fMm W0FvQsWjri1sDYxfA7oYOTkkBEwkjj+9zdLFyMUhJLCDUWLf9yVMEAkZiTfnnwIlOIBsYYnD h4shal4zSmw7/YwRpEZYIEhizc3pzCC2iICKxJ+n/xghirYzSkz9/wPMYRa4zSgx4+0VsKls AtoS7xdMYgWxeQW0JFZMbWQH2cAioCoxd6kqSFhUIEJi9bprzBAlghInZz5hAbE5BQwl3u97 D1bOLKAusX6eEEiYWUBeonnrbOYJjIKzkHTMQqiahaRqASPzKkbJ1ILi3PTcYsMCo7zUcr3i xNzi0rx0veT83E2M4AjS0trBuGfVB71DjEwcjIcYJTiYlUR4BcUfxgnxpiRWVqUW5ccXleak Fh9ilOZgURLn/TprYZyQQHpiSWp2ampBahFMlomDU6qBSe7WuytfNr38ULFayPr+z8+JnR+/ CynUh3uEbpd7+ePyMh5vJVXRaIc5c617dXPrNC0a2Jnur/RWvpctER4hP+/qleznCrv27Fsl EDPTUG/a/xD9+vW9s+ZqpjYtrn9zKKXTKI1BwvTa2s+GeunH5h/xCv+oJVDKaKO9VibYaK+f S882vu43hilH3vg3/s1ylGuYde90z71jxSwB5Wn3XA5Ze32Lm/NdxnCBqXrKKkYzsctbxYsO XU3f6rBV85HS31n73lvYcUZ2fN+b55Sx//axhsJ1oZ0rPK5LGlvbsF71aqx+Fui8w2WBzuvA oz8DdVN3tvafnfunSk723iXpJbHOrOeO885YMG3hqwdXlFiKMxINtZiLihMBWk0VNg8DAAA= X-CMS-MailID: 20200611085414epcas1p11001e9c0488ca816221e2cbb58ab2371 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: SVC_REQ_APPROVE CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20200609095139epcas1p17f9c213de6daf25fe848921bc70481c0 References: <20200609095128.8112-1-jaewon31.kim@samsung.com> <20200610012112.GA239587@google.com> X-Rspamd-Queue-Id: D09B9100E6939 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 Content-Transfer-Encoding: quoted-printable 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 2020=EB=85=84 06=EC=9B=94 10=EC=9D=BC 10:21, Minchan Kim wrote: > Hi Jaewon, > > On Tue, Jun 09, 2020 at 06:51:28PM +0900, Jaewon Kim wrote: >> zone_watermark_fast was introduced by commit 48ee5f3696f6 ("mm, >> page_alloc: shortcut watermark checks for order-0 pages"). The commit >> simply checks if free pages is bigger than watermark without additiona= l >> calculation such like reducing watermark. >> >> It considered free cma pages but it did not consider highatomic >> reserved. This may incur exhaustion of free pages except high order >> atomic free pages. >> >> Assume that reserved_highatomic pageblock is bigger than watermark min= , >> and there are only few free pages except high order atomic free. Becau= se >> zone_watermark_fast passes the allocation without considering high ord= er >> atomic free, normal reclaimable allocation like GFP_HIGHUSER will >> consume all the free pages. Then finally order-0 atomic allocation may >> fail on allocation. >> >> This means watermark min is not protected against non-atomic allocatio= n. >> The order-0 atomic allocation with ALLOC_HARDER unwantedly can be >> failed. Additionally the __GFP_MEMALLOC allocation with >> ALLOC_NO_WATERMARKS also can be failed. >> >> To avoid the problem, zone_watermark_fast should consider highatomic >> reserve. If the actual size of high atomic free is counted accurately >> like cma free, we may use it. On this patch just use >> nr_reserved_highatomic. >> >> This is trace log which shows GFP_HIGHUSER consumes free pages right >> before ALLOC_NO_WATERMARKS. >> >> <...>-22275 [006] .... 889.213383: mm_page_alloc: page=3D00000000d= 2be5665 pfn=3D970744 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213385: mm_page_alloc: page=3D000000004= b2335c2 pfn=3D970745 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213387: mm_page_alloc: page=3D000000000= 17272e1 pfn=3D970278 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213389: mm_page_alloc: page=3D00000000c= 4be79fb pfn=3D970279 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213391: mm_page_alloc: page=3D00000000f= 8a51d4f pfn=3D970260 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213393: mm_page_alloc: page=3D000000006= ba8f5ac pfn=3D970261 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213395: mm_page_alloc: page=3D000000008= 19f1cd3 pfn=3D970196 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> <...>-22275 [006] .... 889.213396: mm_page_alloc: page=3D00000000f= 6b72a64 pfn=3D970197 order=3D0 migratetype=3D0 nr_free=3D3650 gfp_flags=3D= GFP_HIGHUSER|__GFP_ZERO >> kswapd0-1207 [005] ...1 889.213398: mm_page_alloc: page=3D (null) p= fn=3D0 order=3D0 migratetype=3D1 nr_free=3D3650 gfp_flags=3DGFP_NOWAIT|__= GFP_HIGHMEM|__GFP_NOWARN|__GFP_MOVABLE >> >> This is an example of ALLOC_HARDER allocation failure. >> >> <4>[ 6207.637280] [3: Binder:9343_3:22875] Binder:9343_3: page alloc= ation failure: order:0, mode:0x480020(GFP_ATOMIC), nodemask=3D(null) >> <4>[ 6207.637311] [3: Binder:9343_3:22875] Call trace: >> <4>[ 6207.637346] [3: Binder:9343_3:22875] [] dump= _stack+0xb8/0xf0 >> <4>[ 6207.637356] [3: Binder:9343_3:22875] [] warn= _alloc+0xd8/0x12c >> <4>[ 6207.637365] [3: Binder:9343_3:22875] [] __al= loc_pages_nodemask+0x120c/0x1250 >> <4>[ 6207.637374] [3: Binder:9343_3:22875] [] new_= slab+0x128/0x604 >> <4>[ 6207.637381] [3: Binder:9343_3:22875] [] ___s= lab_alloc+0x508/0x670 >> <4>[ 6207.637387] [3: Binder:9343_3:22875] [] __km= alloc+0x2f8/0x310 >> <4>[ 6207.637396] [3: Binder:9343_3:22875] [] cont= ext_struct_to_string+0x104/0x1cc >> <4>[ 6207.637404] [3: Binder:9343_3:22875] [] secu= rity_sid_to_context_core+0x74/0x144 >> <4>[ 6207.637412] [3: Binder:9343_3:22875] [] secu= rity_sid_to_context+0x10/0x18 >> <4>[ 6207.637421] [3: Binder:9343_3:22875] [] seli= nux_secid_to_secctx+0x20/0x28 >> <4>[ 6207.637430] [3: Binder:9343_3:22875] [] secu= rity_secid_to_secctx+0x3c/0x70 >> <4>[ 6207.637442] [3: Binder:9343_3:22875] [] bind= er_transaction+0xe68/0x454c >> <4>[ 6207.637569] [3: Binder:9343_3:22875] Mem-Info: >> <4>[ 6207.637595] [3: Binder:9343_3:22875] active_anon:102061 inacti= ve_anon:81551 isolated_anon:0 >> <4>[ 6207.637595] [3: Binder:9343_3:22875] active_file:59102 inacti= ve_file:68924 isolated_file:64 >> <4>[ 6207.637595] [3: Binder:9343_3:22875] unevictable:611 dirty:63= writeback:0 unstable:0 >> <4>[ 6207.637595] [3: Binder:9343_3:22875] slab_reclaimable:13324 s= lab_unreclaimable:44354 >> <4>[ 6207.637595] [3: Binder:9343_3:22875] mapped:83015 shmem:4858 = pagetables:26316 bounce:0 >> <4>[ 6207.637595] [3: Binder:9343_3:22875] free:2727 free_pcp:1035 = free_cma:178 >> <4>[ 6207.637616] [3: Binder:9343_3:22875] Node 0 active_anon:408244= kB inactive_anon:326204kB active_file:236408kB inactive_file:275696kB une= victable:2444kB isolated(anon):0kB isolated(file):256kB mapped:332060kB d= irty:252kB writeback:0kB shmem:19432kB writeback_tmp:0kB unstable:0kB all= _unreclaimable? no >> <4>[ 6207.637627] [3: Binder:9343_3:22875] Normal free:10908kB min:6= 192kB low:44388kB high:47060kB active_anon:409160kB inactive_anon:325924k= B active_file:235820kB inactive_file:276628kB unevictable:2444kB writepen= ding:252kB present:3076096kB managed:2673676kB mlocked:2444kB kernel_stac= k:62512kB pagetables:105264kB bounce:0kB free_pcp:4140kB local_pcp:40kB f= ree_cma:712kB >> <4>[ 6207.637632] [3: Binder:9343_3:22875] lowmem_reserve[]: 0 0 >> <4>[ 6207.637637] [3: Binder:9343_3:22875] Normal: 505*4kB (H) 357*8= kB (H) 201*16kB (H) 65*32kB (H) 1*64kB (H) 0*128kB 0*256kB 0*512kB 0*1024= kB 0*2048kB 0*4096kB =3D 10236kB >> <4>[ 6207.637655] [3: Binder:9343_3:22875] 138826 total pagecache pa= ges >> <4>[ 6207.637663] [3: Binder:9343_3:22875] 5460 pages in swap cache >> <4>[ 6207.637668] [3: Binder:9343_3:22875] Swap cache stats: add 827= 3090, delete 8267506, find 1004381/4060142 >> >> This is an example of ALLOC_NO_WATERMARKS allocation failure. >> >> <6>[ 156.701551] [4: kswapd0: 1209] kswapd0 cpuset=3D/ mems_a= llowed=3D0 >> <4>[ 156.701563] [4: kswapd0: 1209] CPU: 4 PID: 1209 Comm: ks= wapd0 Tainted: G W 4.14.113-18113966 #1 >> <4>[ 156.701572] [4: kswapd0: 1209] Call trace: >> <4>[ 156.701605] [4: kswapd0: 1209] [<0000000000000000>] dump= _stack+0x68/0x90 >> <4>[ 156.701612] [4: kswapd0: 1209] [<0000000000000000>] warn= _alloc+0x104/0x198 >> <4>[ 156.701617] [4: kswapd0: 1209] [<0000000000000000>] __al= loc_pages_nodemask+0xdc0/0xdf0 >> <4>[ 156.701623] [4: kswapd0: 1209] [<0000000000000000>] zs_m= alloc+0x148/0x3d0 >> <4>[ 156.701630] [4: kswapd0: 1209] [<0000000000000000>] zram= _bvec_rw+0x250/0x568 >> <4>[ 156.701634] [4: kswapd0: 1209] [<0000000000000000>] zram= _rw_page+0x8c/0xe0 >> <4>[ 156.701640] [4: kswapd0: 1209] [<0000000000000000>] bdev= _write_page+0x70/0xbc >> <4>[ 156.701645] [4: kswapd0: 1209] [<0000000000000000>] __sw= ap_writepage+0x58/0x37c >> <4>[ 156.701649] [4: kswapd0: 1209] [<0000000000000000>] swap= _writepage+0x40/0x4c >> <4>[ 156.701654] [4: kswapd0: 1209] [<0000000000000000>] shri= nk_page_list+0xc3c/0xf54 >> <4>[ 156.701659] [4: kswapd0: 1209] [<0000000000000000>] shri= nk_inactive_list+0x2b0/0x61c >> <4>[ 156.701664] [4: kswapd0: 1209] [<0000000000000000>] shri= nk_node_memcg+0x23c/0x618 >> <4>[ 156.701668] [4: kswapd0: 1209] [<0000000000000000>] shri= nk_node+0x1c8/0x304 >> <4>[ 156.701673] [4: kswapd0: 1209] [<0000000000000000>] kswa= pd+0x680/0x7c4 >> <4>[ 156.701679] [4: kswapd0: 1209] [<0000000000000000>] kthr= ead+0x110/0x120 >> <4>[ 156.701684] [4: kswapd0: 1209] [<0000000000000000>] ret_= from_fork+0x10/0x18 >> <4>[ 156.701689] [4: kswapd0: 1209] Mem-Info: >> <4>[ 156.701712] [4: kswapd0: 1209] active_anon:88690 inactiv= e_anon:88630 isolated_anon:0 >> <4>[ 156.701712] [4: kswapd0: 1209] active_file:99173 inacti= ve_file:169305 isolated_file:32 >> <4>[ 156.701712] [4: kswapd0: 1209] unevictable:48292 dirty:= 538 writeback:38 unstable:0 >> <4>[ 156.701712] [4: kswapd0: 1209] slab_reclaimable:15131 s= lab_unreclaimable:47762 >> <4>[ 156.701712] [4: kswapd0: 1209] mapped:274654 shmem:2824= pagetables:25088 bounce:0 >> <4>[ 156.701712] [4: kswapd0: 1209] free:2489 free_pcp:444 f= ree_cma:3 >> <4>[ 156.701728] [4: kswapd0: 1209] Node 0 active_anon:354760= kB inactive_anon:354520kB active_file:396692kB inactive_file:677220kB une= victable:193168kB isolated(anon):0kB isolated(file):128kB mapped:1098616k= B dirty:2152kB writeback:152kB shmem:11296kB writeback_tmp:0kB unstable:0= kB all_unreclaimable? no >> <4>[ 156.701738] [4: kswapd0: 1209] Normal free:9956kB min:74= 28kB low:93440kB high:97032kB active_anon:355176kB inactive_anon:354580kB= active_file:396196kB inactive_file:677284kB unevictable:193168kB writepe= nding:2304kB present:4081664kB managed:3593324kB mlocked:193168kB kernel_= stack:55008kB pagetables:100352kB bounce:0kB free_pcp:1776kB local_pcp:65= 6kB free_cma:12kB >> <4>[ 156.701741] [4: kswapd0: 1209] lowmem_reserve[]: 0 0 >> <4>[ 156.701747] [4: kswapd0: 1209] Normal: 196*4kB (H) 141*8= kB (H) 109*16kB (H) 63*32kB (H) 20*64kB (H) 8*128kB (H) 2*256kB (H) 1*512= kB (H) 0*1024kB 0*2048kB 0*4096kB =3D 9000kB >> >> Signed-off-by: Jaewon Kim >> Reported-by: Yong-Taek Lee >> --- >> mm/page_alloc.c | 13 +++++++++++-- >> 1 file changed, 11 insertions(+), 2 deletions(-) >> >> diff --git a/mm/page_alloc.c b/mm/page_alloc.c >> index 13cc653122b7..00869378d387 100644 >> --- a/mm/page_alloc.c >> +++ b/mm/page_alloc.c >> @@ -3553,6 +3553,11 @@ static inline bool zone_watermark_fast(struct z= one *z, unsigned int order, >> { >> long free_pages =3D zone_page_state(z, NR_FREE_PAGES); >> long cma_pages =3D 0; >> + long highatomic =3D 0; >> + const bool alloc_harder =3D (alloc_flags & (ALLOC_HARDER|ALLOC_OOM))= ; >> + >> + if (likely(!alloc_harder)) >> + highatomic =3D z->nr_reserved_highatomic; >> =20 >> #ifdef CONFIG_CMA >> /* If allocation can't use CMA areas don't use free CMA pages */ >> @@ -3567,8 +3572,12 @@ static inline bool zone_watermark_fast(struct z= one *z, unsigned int order, >> * the caller is !atomic then it'll uselessly search the free >> * list. That corner case is then slower but it is harmless. >> */ >> - if (!order && (free_pages - cma_pages) > mark + z->lowmem_reserve[cl= asszone_idx]) >> - return true; >> + if (!order) { >> + long fast_free =3D free_pages - cma_pages - highatomic; > > With your change, it seems we share most code for getting free_pages=20 > between zone_watermark_fast and __zone_watermark_ok. Only difference > between them is min calculation. If so, can we share most code between > them via introducing like __zone_watermark_free static inline function? > So, we didn't miss one place in future if we change something. > Hello thank you for your comment. I tried to share some code. Because __zone_watermark_ok gets free pages as argument, I just could make a function calculating unusable free. static inline long __zone_watermark_unusable_free(struct zone *z, unsigned int alloc_fl= ags) on zone_watermark_fast free_pages -=3D __zone_watermark_unusable_free(z, alloc_flags); on __zone_watermark_ok free_pages -=3D __zone_watermark_unusable_free(z, alloc_flags); Let me get your comment prior to v2 change. Thank you Jaewon Kim >> + >> + if (fast_free > mark + z->lowmem_reserve[classzone_idx]) >> + return true; >> + } >> =20 >> return __zone_watermark_ok(z, order, mark, classzone_idx, alloc_flag= s, >> free_pages); >> --=20 >> 2.17.1 >> >