From patchwork Thu Nov 5 19:15:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rik van Riel X-Patchwork-Id: 11884987 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 4E61016C1 for ; Thu, 5 Nov 2020 19:15:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8DBD62151B for ; Thu, 5 Nov 2020 19:15:27 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8DBD62151B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=surriel.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 255396B0180; Thu, 5 Nov 2020 14:15:24 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 22B556B0181; Thu, 5 Nov 2020 14:15:24 -0500 (EST) 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 1177F6B0182; Thu, 5 Nov 2020 14:15:24 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0241.hostedemail.com [216.40.44.241]) by kanga.kvack.org (Postfix) with ESMTP id DAB756B0181 for ; Thu, 5 Nov 2020 14:15:23 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 7B3608249980 for ; Thu, 5 Nov 2020 19:15:23 +0000 (UTC) X-FDA: 77451318126.09.tax52_5d0b1b0272cc Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 5BDB3180AD801 for ; Thu, 5 Nov 2020 19:15:23 +0000 (UTC) X-Spam-Summary: 1,0,0,9f0bd62a17616749,d41d8cd98f00b204,riel@shelob.surriel.com,,RULES_HIT:41:355:379:541:966:973:988:989:1260:1311:1314:1345:1437:1515:1534:1541:1711:1730:1747:1777:1792:2196:2199:2393:2559:2562:2693:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3870:3874:4250:4385:5007:6117:6119:6120:6261:7901:7903:10004:11026:11658:11914:12043:12050:12296:12297:12438:12517:12519:13069:13161:13229:13311:13357:13894:14096:14384:14394:14721:14819:21080:21451:21627:21740:30012:30054:30091,0,RBL:96.67.55.147:@shelob.surriel.com:.lbl8.mailshell.net-64.201.201.201 62.14.0.100;04yro7t3nmp3b48iadhd7ofbemjinypadt1r13ojjo9h6wxyj9ehh1b3chz6oab.okm196587aiprxbsy3dgu6idsrdwuka9qrrrfstgyhr6hieahkfnuypgdgqgt7k.g-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:72,LUA_SUMMARY:none X-HE-Tag: tax52_5d0b1b0272cc X-Filterd-Recvd-Size: 2359 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Thu, 5 Nov 2020 19:15:22 +0000 (UTC) Received: from imladris.surriel.com ([96.67.55.152]) by shelob.surriel.com with esmtpsa (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94) (envelope-from ) id 1kakj1-00048T-Bd; Thu, 05 Nov 2020 14:15:11 -0500 From: Rik van Riel To: hughd@google.com Cc: xuyu@linux.alibaba.com, akpm@linux-foundation.org, mgorman@suse.de, aarcange@redhat.com, willy@infradead.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, linux-mm@kvack.org, vbabka@suse.cz, mhocko@suse.com Subject: [PATCH 0/2] mm,thp,shm: limit shmem THP alloc gfp_mask Date: Thu, 5 Nov 2020 14:15:06 -0500 Message-Id: <20201105191508.1961686-1-riel@surriel.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 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 allocation flags of anonymous transparent huge pages can be controlled through the files in /sys/kernel/mm/transparent_hugepage/defrag, which can help the system from getting bogged down in the page reclaim and compaction code when many THPs are getting allocated simultaneously. However, the gfp_mask for shmem THP allocations were not limited by those configuration settings, and some workloads ended up with all CPUs stuck on the LRU lock in the page reclaim code, trying to allocate dozens of THPs simultaneously. This patch applies the same configurated limitation of THPs to shmem hugepage allocations, to prevent that from happening. This way a THP defrag setting of "never" or "defer+madvise" will result in quick allocation failures without direct reclaim when no 2MB free pages are available. With this patch applied, THP allocations for tmpfs will be a little more aggressive than today for files mmapped with MADV_HUGEPAGE, and a little less aggressive for files that are not mmapped or mapped without that flag. v5: reduce gfp mask further if needed, to accomodate i915 (Matthew Wilcox) v4: rename alloc_hugepage_direct_gfpmask to vma_thp_gfp_mask (Matthew Wilcox) v3: fix NULL vma issue spotted by Hugh Dickins & tested v2: move gfp calculation to shmem_getpage_gfp as suggested by Yu Xu