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=-6.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS 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 C70D4C4363A for ; Thu, 22 Oct 2020 08:15:37 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 305C321481 for ; Thu, 22 Oct 2020 08:15:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="u4+/bAId" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 305C321481 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 9394A6B006C; Thu, 22 Oct 2020 04:15:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C3416B006E; Thu, 22 Oct 2020 04:15:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 78D536B0070; Thu, 22 Oct 2020 04:15:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0019.hostedemail.com [216.40.44.19]) by kanga.kvack.org (Postfix) with ESMTP id 496B06B006C for ; Thu, 22 Oct 2020 04:15:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CD07A822A29D for ; Thu, 22 Oct 2020 08:15:35 +0000 (UTC) X-FDA: 77398852230.29.metal13_3e073472724f Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin29.hostedemail.com (Postfix) with ESMTP id 97A76180868E0 for ; Thu, 22 Oct 2020 08:15:35 +0000 (UTC) X-HE-Tag: metal13_3e073472724f X-Filterd-Recvd-Size: 3834 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Thu, 22 Oct 2020 08:15:35 +0000 (UTC) X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1603354533; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VBy6UP5t6Wl5y2nB0PcKMFAyqskTOmW6bMTiFToXfPQ=; b=u4+/bAIdO3ZACffTeN4vN1PGN8C8vG9AE7IzoXz+z0DB/7eaETz+DXvRgXBVWUpP/eWloB pfN0tF4c7EUQLOELgpoD9hQ3xhEr61WNSShCYquOCjrzqMH0IJ0+quXEwryC++5horgzHe 2sm7WBdzGxEFGnD92o3fcqet4hWJWg4= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id D182FAECE; Thu, 22 Oct 2020 08:15:33 +0000 (UTC) Date: Thu, 22 Oct 2020 10:15:32 +0200 From: Michal Hocko To: Rik van Riel Cc: Hugh Dickins , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-team@fb.com, Mel Gorman , Andrea Arcangeli , Matthew Wilcox Subject: Re: [PATCH] mm,thp,shmem: limit shmem THP alloc gfp_mask Message-ID: <20201022081532.GJ23790@dhcp22.suse.cz> References: <20201021234846.5cc97e62@imladris.surriel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201021234846.5cc97e62@imladris.surriel.com> 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 Wed 21-10-20 23:48:46, Rik van Riel wrote: > 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. I remmeber I wanted to unify this in the past as well. The patch got reverted in the end. It was a long story and I do not have time to read through lengthy discussions again. I do remember though that there were some objections pointing out that shmem has its own behavior which is controlled by the mount option - at least for the explicitly mounted shmems. I might misremember. [...] > diff --git a/mm/shmem.c b/mm/shmem.c > index 537c137698f8..d1290eb508e5 100644 > --- a/mm/shmem.c > +++ b/mm/shmem.c > @@ -1545,8 +1545,11 @@ static struct page *shmem_alloc_hugepage(gfp_t gfp, > return NULL; > > shmem_pseudo_vma_init(&pvma, info, hindex); > - page = alloc_pages_vma(gfp | __GFP_COMP | __GFP_NORETRY | __GFP_NOWARN, > - HPAGE_PMD_ORDER, &pvma, 0, numa_node_id(), true); > + /* Limit the gfp mask according to THP configuration. */ > + gfp |= __GFP_COMP | __GFP_NORETRY | __GFP_NOWARN; What is the reason for these when alloc_hugepage_direct_gfpmask provides the full mask? > + gfp &= alloc_hugepage_direct_gfpmask(&pvma); > + page = alloc_pages_vma(gfp, HPAGE_PMD_ORDER, &pvma, 0, numa_node_id(), > + true); > shmem_pseudo_vma_destroy(&pvma); > if (page) > prep_transhuge_page(page); > > -- > All rights reversed. -- Michal Hocko SUSE Labs