Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp5432174pxu; Thu, 22 Oct 2020 02:02:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzF3POJ95XaK0IbF3d+I+QhnY2BMcM6zK3fLIpzn3p4R4OM3cL9aqVHvoG/AROlOcDpz+kn X-Received: by 2002:a17:906:6bce:: with SMTP id t14mr1377329ejs.118.1603357365434; Thu, 22 Oct 2020 02:02:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603357365; cv=none; d=google.com; s=arc-20160816; b=uHHm3Ff1JLBOvqcO3aCyGlOF6w3u32lThM6z2BylDt/wurH0MQFs3ZQI1bFhzWtbVf tV6VpddssmB1c2VuyrD/75v4j5HB0pS+BKWbW/VSsJ5wSiXoJrs6hh4arzqQZpB1lWsh +JGCBFdcHlm7ttOGOeAvCBvWpAKSvaFIKYqxrGgA8RCOdq+TmDKReEwhHuenzj7FLnG2 QdqU4RCQ6zQ8ixiJ1S7Ys/x4LhhYOql252yE18Qvon7gXJqwSgrZcpsAJcX+RZ/+jpCD U2z/rLAYIGj8Sk6vmkvWIZlR325C2W0Rl0ez0iNA5Z9VwkdwYL6OwrM7LLwNbbPGHqy3 Zsew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VBy6UP5t6Wl5y2nB0PcKMFAyqskTOmW6bMTiFToXfPQ=; b=HUUUsATCTFYKdWDOguu7BOHNd4OtJWxcCYQjb1VEYjh/0k3R8cf1THNQIhQfZWH3nY wxA/mlpa7RYUwIGQEQhdCq9UneEvr9gpjM1iPAs3v0XrJ86plSynpNxmJuoNuMS6xyYd hpYqukKE2StG9/ohdFEn4RaaQI4KP6uozHdtnfl8L8DZ0uit1LvQmq9quXJWwymYk4UH Zlp4AHy8EXWbr3RrVRqplcLWINXibx7YnE1HABc7qkCeO+bYvk8yAVZr9DE3N7+AdkCG 4At8xV7sHBCGxT8EW3+0ZfeLxC2pTLnOeJQ6BGmAL6JBdfjN30va8mB9rkibO1FSVUP9 X1Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b="u4+/bAId"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a34si567760edf.260.2020.10.22.02.02.22; Thu, 22 Oct 2020 02:02:45 -0700 (PDT) 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; dkim=pass header.i=@suse.com header.s=susede1 header.b="u4+/bAId"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2894739AbgJVIPg (ORCPT + 99 others); Thu, 22 Oct 2020 04:15:36 -0400 Received: from mx2.suse.de ([195.135.220.15]:54652 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2443493AbgJVIPf (ORCPT ); Thu, 22 Oct 2020 04:15:35 -0400 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> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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