From patchwork Tue Nov 24 19:49:22 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: 11929783 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=-6.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=no 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 D8AABC6379D for ; Tue, 24 Nov 2020 19:49:45 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 75CEB208CA for ; Tue, 24 Nov 2020 19:49:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 75CEB208CA 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 872AB6B006E; Tue, 24 Nov 2020 14:49:40 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7FAFB6B0070; Tue, 24 Nov 2020 14:49:40 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6EA296B0071; Tue, 24 Nov 2020 14:49:40 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0173.hostedemail.com [216.40.44.173]) by kanga.kvack.org (Postfix) with ESMTP id 55A4B6B006E for ; Tue, 24 Nov 2020 14:49:40 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 10E3F180AD806 for ; Tue, 24 Nov 2020 19:49:40 +0000 (UTC) X-FDA: 77520351720.05.trees75_61178e527370 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin05.hostedemail.com (Postfix) with ESMTP id E7F03180279BD for ; Tue, 24 Nov 2020 19:49:39 +0000 (UTC) X-HE-Tag: trees75_61178e527370 X-Filterd-Recvd-Size: 2414 Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) by imf35.hostedemail.com (Postfix) with ESMTP for ; Tue, 24 Nov 2020 19:49:38 +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 1kheJb-0006wM-Vy; Tue, 24 Nov 2020 14:49:28 -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 v6 0/3] mm,thp,shm: limit shmem THP alloc gfp_mask Date: Tue, 24 Nov 2020 14:49:22 -0500 Message-Id: <20201124194925.623931-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. v6: make khugepaged actually obey tmpfs mount flags 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