Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp2050324pxu; Tue, 24 Nov 2020 15:54:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOlRhLjwTBm/PJ3UWVxTlX6kLi7iFV3yvOV5GBSRgvi/Lagw/23qOnsHCtJ5xIKFW8Vi/K X-Received: by 2002:a50:875d:: with SMTP id 29mr1024163edv.172.1606262059789; Tue, 24 Nov 2020 15:54:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606262059; cv=none; d=google.com; s=arc-20160816; b=iI5gEfInP+RYTYNnKKdeRwuNKYZyLayZXkBAv7VuesnC/3d8qYpwGBjuCxMUARn2Fw 5Koe7Sc7KXgqiqEyK4dC9GPjMGHLxcr5MFqi7WwJTi03YfJf3knJst4JESUJGPIoi6b6 LT2mH6N6d/3rgJzxt4t6S3QQ6QAfNhQ34nzXZz/WvlWIw+E+2NOAZH9zbw02sNftp/nL Yo37cJVLiFzwfyeMlqYQboMhVlZvTSfiZ495EJBENghOyCt3hFPLyqhFlaPZAAMWrylW GS05a96mPJi7jxPHxKXXrR3JrUuCZT2FAbGwseNRt1OexSsGV334ymiKuPVfjX4000i7 RpqA== 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:mime-version :message-id:date:subject:cc:to:from; bh=SY/1eO1AMsIhlLbYdHlTxAusdBPQYZ8kUNIuz6Z/GkI=; b=Ev1gZPbyvkIOTtel98oGgY0FixTRfz0Fd9tAtjXpDow4ToX3PwZlmpJ+zITYPy1DoH t/fonoTv+5xm4Ko+CR7N7LB0ru70gRgLXPC5CfNDzMwv1UHvq/7V2vRgZX/55lS2TfrG hoZ0Id5YNy8zlpZvMR+r4ZV5/Odg1vUO2DylyxpvkQZPXSjsMPc/Y4kX9jf04fDVL1Up f/fkO/KRSS5X3c7g5SAWUxYvU7y1yULlvl6qgbPRWvs23u8o0/Xz6x1zK7vP9RNW0kgc 4n8OeXENumaCUxkYaNKRq59N66Fz1PmgRVU96kcpYYZwi1u/Pe7Sjsl97rRT2/rsB7AH 4p8Q== ARC-Authentication-Results: i=1; mx.google.com; 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 j15si279036ejv.71.2020.11.24.15.53.56; Tue, 24 Nov 2020 15:54:19 -0800 (PST) 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; 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 S1726969AbgKXTtj (ORCPT + 99 others); Tue, 24 Nov 2020 14:49:39 -0500 Received: from shelob.surriel.com ([96.67.55.147]:36702 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726447AbgKXTti (ORCPT ); Tue, 24 Nov 2020 14:49:38 -0500 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 Content-Transfer-Encoding: 8bit Sender: riel@shelob.surriel.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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