Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp726494pxb; Thu, 5 Nov 2020 11:18:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyxrzi3RMatqCp1YymD4tP3Sb+Z7LxqZdHEzzJJB1K3WjpS46Ba8dlYHeveG1xf64m+Ii/O X-Received: by 2002:a17:906:d79a:: with SMTP id pj26mr3775590ejb.378.1604603885673; Thu, 05 Nov 2020 11:18:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604603885; cv=none; d=google.com; s=arc-20160816; b=LqEpkBw5C+VJi5mwOZoyQ1Y12oM4QfBeirHhLTn6xAELpdloEl+Z+RtDzAI1NUrcZJ E8eC58osqmapJw5K5qp78EptfBpvxrgsUP423Ph6DASFDWtBKhC8x9A4M/o6y2wCzyaB ympdZLkNcrryuZgV2MhLNSSluDzt3Fq4tS+fK4yI+fvJeVrbg1C2pFgxoxL4cd+oqzh1 zCPgJB3TJ5XSec3by0/K4sSSfm79dluLfn+CKxu9H5Fy/zbDZcQtw+yH9ejN57fkdOgC RF6jajY+59hPF48inN6Ss24E3ItPSRpjGBRq6jvLPJzz9SAaxZS2kEkK6H7fMoqD3mla MtQQ== 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=50K1Ril18hwlM55xZwCej3OJxmsnSCTc9Qu0nzjU6aA=; b=G/aBST3MWLdWH4kN5VpbHjCA9YxqtP0n9XfELZ661eX8LMlzUrp9hlFvbpEHk4PIWA C/z23xffamG7CzQMp3CUbjpM4hiJoZYPPcUjwc0TdO1A4WfrF8r/Vg5eUpFrtb0Rbqv9 pbyIE8ViGjTjA1ZfLoDyO3W7/sd7i2iGJiuixHRUrQzyHiuo5pVZeTP80xqmcp40KfD/ BQ56gQoeBpEZAJ6TQnhr3i/HzzhupLYxpBuH0tj8AwDWjICuF1AmPWILLGUTL8kaj5PQ eP/ESU/x5pIxMDtKIraOUeUwHtxjr/ed41OuxXOAiEQgl8mysh3i5IArOcQzMhhi2O3Z TpqQ== 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 o19si1221984edq.24.2020.11.05.11.17.43; Thu, 05 Nov 2020 11:18:05 -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 S1731990AbgKETPW (ORCPT + 99 others); Thu, 5 Nov 2020 14:15:22 -0500 Received: from shelob.surriel.com ([96.67.55.147]:60542 "EHLO shelob.surriel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731965AbgKETPW (ORCPT ); Thu, 5 Nov 2020 14:15:22 -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 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 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. 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