Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp914384ybh; Tue, 10 Mar 2020 10:40:32 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsof2BP+593BDcb91pD00yvEMH47Etps9bAMPe4PUUWp3Nvy1lShd957JAQDSsBvH2VFUSG X-Received: by 2002:a9d:7d0c:: with SMTP id v12mr17904992otn.171.1583862032227; Tue, 10 Mar 2020 10:40:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583862032; cv=none; d=google.com; s=arc-20160816; b=yKxF8VjbRlbT9XCIzUDo36u2npmi/xgrr5ZNYOi4Qq3nlcHDil/rWpk9hjBxU+ulVj z2Vu1+YHx5yeDL8Ji/3iMDFUK9x7hQQ+8Q5n3CA5qwVy4ijurr7oMkvFl7BlGmZCbjxl tAp7+j84gk+oxoMWi2SEYKCIvDISE9lpShMPJzTJTfI2qhivKHJ0E2O05/5iw6PM7bEn fNx3Np8+5d3sh/wu6rQ4pzjw/tpYVyHZD/ixMqM6bc/gPreSJmZK1RRpmI2iV+HXJRt5 F6ynbbMYYljMJQlu3MBYd9K8Q/C464UQWC4SfGqHsL4zSr5kVtXsAGX8i7oUGRNvfUdN CkWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=mi8lNzzOnKeYsD5u8ot6xkdW2xJgJMBQyDw8ffSdpAY=; b=b/oWLKD3jmusTD309t2kz32u7/dHk7FZZ0VAU6jGYA+TmErz6KjPBchfVzAbKxnnf3 vxbM0vuWzN3qkymgTUz1t1umI9BOZKaSvsT2H1nj1VRY5hhPB4caKJznT5J2Xa6UTwoz wiJ2sr4tDPOE2Z58YTRG+lujBMiHhmnbfve7Tc3a/e7Zh07H4RDwa4N2VeVHpxiCrwak Dn/LU7abltplMk0aDgWx94lctMWwiCYWEmwgBkM7XGyi62f3VZgQyEueSQSwr1jT8jga 9gYIiztQopKY5EqaZwm7fTOk3ydjJzALtbHffoh1GUIiZ1WzQm5ynSRR6reDHNREHMmg 11SA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v19si7962821otq.57.2020.03.10.10.40.18; Tue, 10 Mar 2020 10:40:32 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726674AbgCJRjz (ORCPT + 99 others); Tue, 10 Mar 2020 13:39:55 -0400 Received: from mail-wm1-f65.google.com ([209.85.128.65]:39146 "EHLO mail-wm1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726271AbgCJRjz (ORCPT ); Tue, 10 Mar 2020 13:39:55 -0400 Received: by mail-wm1-f65.google.com with SMTP id f7so2353978wml.4 for ; Tue, 10 Mar 2020 10:39:54 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=mi8lNzzOnKeYsD5u8ot6xkdW2xJgJMBQyDw8ffSdpAY=; b=Sc8YqEzgMyj+9jAsW15y1MGX58durmfcxD7UvIbvirQp5d8n5sG+HNF6C0AZUxbkOV 3wYkSq6Vwge5XaosiqlTBk6g3a8EVykouLyxduyDMTw6tj/eFCtTL+sU1U1zEdhbfiip 3I6Hb9ETeb2KLZOQ2Dy6n2GbY7k8iKgquPnVU7IdV0AOistFAiOUkscPhMXGLucXQnrE 9LqB6GZfG2QoMsgYG4V5u1YGaVTJa3k3ppfaV/CHx6FHJPtQRBIAwlz6m51RaSG5RhtL Lci+HHs6gPfV9P/z3mrPg0Y5u7vozma5lRjc04S9GdDjkTjtsXsvH7ROaWd9W6XODFbu HiKg== X-Gm-Message-State: ANhLgQ1tRQLrb02EuK0tFAGvYNgJEZ8c8xW5uGTpgKaDcDEJRO9bWyQm 6P1W4bXYeswyHvfIWgIyrGA= X-Received: by 2002:a1c:9c4c:: with SMTP id f73mr3048235wme.125.1583861993519; Tue, 10 Mar 2020 10:39:53 -0700 (PDT) Received: from localhost (ip-37-188-253-35.eurotel.cz. [37.188.253.35]) by smtp.gmail.com with ESMTPSA id q6sm4893875wmj.6.2020.03.10.10.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2020 10:39:52 -0700 (PDT) Date: Tue, 10 Mar 2020 18:39:51 +0100 From: Michal Hocko To: Roman Gushchin Cc: Andrew Morton , Johannes Weiner , linux-mm@kvack.org, kernel-team@fb.com, linux-kernel@vger.kernel.org, Rik van Riel , Mike Kravetz Subject: Re: [PATCH v2] mm: hugetlb: optionally allocate gigantic hugepages using cma Message-ID: <20200310173951.GX8447@dhcp22.suse.cz> References: <20200310002524.2291595-1-guro@fb.com> <20200310090121.GB8447@dhcp22.suse.cz> <20200310173056.GB85000@carbon.dhcp.thefacebook.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200310173056.GB85000@carbon.dhcp.thefacebook.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue 10-03-20 10:30:56, Roman Gushchin wrote: > On Tue, Mar 10, 2020 at 10:01:21AM +0100, Michal Hocko wrote: > > On Mon 09-03-20 17:25:24, Roman Gushchin wrote: > > [...] > > > 2) Run-time allocations of gigantic hugepages are performed using the > > > cma allocator and the dedicated cma area > > > > [...] > > > @@ -1237,6 +1246,23 @@ static struct page *alloc_gigantic_page(struct hstate *h, gfp_t gfp_mask, > > > { > > > unsigned long nr_pages = 1UL << huge_page_order(h); > > > > > > + if (IS_ENABLED(CONFIG_CMA) && hugetlb_cma[0]) { > > > + struct page *page; > > > + int nid; > > > + > > > + for_each_node_mask(nid, *nodemask) { > > > + if (!hugetlb_cma[nid]) > > > + break; > > > + > > > + page = cma_alloc(hugetlb_cma[nid], nr_pages, > > > + huge_page_order(h), true); > > > + if (page) > > > + return page; > > > + } > > > + > > > + return NULL; > > > > Is there any strong reason why the alloaction annot fallback to non-CMA > > allocator when the cma is depleted? > > The reason is that that gigantic pages allocated using cma require > a special handling on releasing. It's solvable by using an additional > page flag, but because the current code is usually not working except > a short time just after the system start, I don't think it's worth it. I am not deeply familiar with the cma much TBH but cma_release seems to be documented to return false if the area doesn't belong to the area so the free patch can try cma_release and fallback to the regular free, no? -- Michal Hocko SUSE Labs