Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp57679imm; Fri, 25 May 2018 14:11:15 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpo/3JhQErD4RlRNDmrwk4U4U3ao/SBl/hEdO5xCDUMf5NlnasO+iYObydFJRSWiKfkQQkg X-Received: by 2002:a62:ccdc:: with SMTP id j89-v6mr4171250pfk.182.1527282675891; Fri, 25 May 2018 14:11:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527282675; cv=none; d=google.com; s=arc-20160816; b=ti3or9/z+AfdBRTSmfZ1eaiUrIMbucezvgY0TAcClQKc1tZme3j/jyeh+bgyP6MJmd K6c6ASKAGk/gtSivSJTnrrTAB4o4lUdxAZN1qhlMrxIQMizCs0Fbzm8ATbTqHRAuj9JP abYJrDu+qForwktPBsQ6CQ7VJYgOJjuoHa2PLLCAJ4kM39LVxzTz3X/60+BThDlwVcZS u8QGHgWFedAxtSHeGVksm+/3FBOIlFoEZA2jhR1FWzuO7itVJ+InWNrYVOnwhoCyjVcK vCC8Ho6YV1rshdi3V+QO3si94G05dePLHr6Jeo6qJq/FJcXe0G99S6lTTwp242F4Yei3 HcyA== 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 :references:in-reply-to:message-id:subject:cc:to:from:date :arc-authentication-results; bh=I4XrD0gZeXHlTmucA0pMEp+cFzdR0pvrHcPtet4XwTs=; b=AlpjsIb+mSYzPKrp9jYjN5S0+eavB8OsN+R5EMeuPIceFBElPibLOAeB0t5JJ1gpgt DCUpWNDRsInUg9kj+5gJc+L5Az3IvzBDHJnM2pcleaC2gqcDu+bqrZjDk7eqFushWpSi 6GWNoK8B9qPC10hnNcWjNaScBcUFgZO4PmIPgyhkdr9qikouY53Lis3ZHkLHhCq+VO9q wg4IVNjQPmPsiJD1RwpkE70ZrRUgf4rG4G1LjqR6Pqm/iS3LkDqYS+nKvuXU4UVNTGmA BcZRnrkg7lvNaNSGZT1NPRG9qEUsYTNon6Pmyd2ZQSHSU74Oeb4cUxaJLbokxb/ORh4d 42pQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b12-v6si25032469plr.42.2018.05.25.14.11.01; Fri, 25 May 2018 14:11:15 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1030344AbeEYVJn (ORCPT + 99 others); Fri, 25 May 2018 17:09:43 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:47020 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S968411AbeEYVJm (ORCPT ); Fri, 25 May 2018 17:09:42 -0400 Received: from akpm3.svl.corp.google.com (unknown [104.133.9.71]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id E5515E69; Fri, 25 May 2018 21:09:41 +0000 (UTC) Date: Fri, 25 May 2018 14:09:40 -0700 From: Andrew Morton To: David Rientjes Cc: Mike Kravetz , "Aneesh Kumar K.V" , Naoya Horiguchi , Vlastimil Babka , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [patch] mm, hugetlb_cgroup: suppress SIGBUS when hugetlb_cgroup charge fails Message-Id: <20180525140940.976ca667f3c6ff83238c3620@linux-foundation.org> In-Reply-To: References: <20180525134459.5c6f8e06f55307f72b95a901@linux-foundation.org> X-Mailer: Sylpheed 3.6.0 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 25 May 2018 13:59:40 -0700 (PDT) David Rientjes wrote: > > > --- a/mm/hugetlb.c > > > +++ b/mm/hugetlb.c > > > @@ -2006,8 +2006,10 @@ struct page *alloc_huge_page(struct vm_area_struct *vma, > > > * code of zero indicates a reservation exists (no change). > > > */ > > > map_chg = gbl_chg = vma_needs_reservation(h, vma, addr); > > > - if (map_chg < 0) > > > - return ERR_PTR(-ENOMEM); > > > + if (map_chg < 0) { > > > + ret = -ENOMEM; > > > + goto out; > > > + } > > > > This doesn't change the return value. > > > > This, and the subsequent comments, are referring to the third paragraph of > the changelog. > > The functional part of the change is for the > hugetlb_cgroup_charge_cgroup() return value that is now actually used. Ah. Missed that bit. Altered changelog: : When charging to a hugetlb_cgroup fails, alloc_huge_page() returns : ERR_PTR(-ENOSPC) which will cause VM_FAULT_SIGBUS to be returned to the : page fault handler. : : This is because the return value from hugetlb_cgroup_charge_cgroup() is : overwritten with ERR_PTR(-ENOSPC). : : Instead, propagate the error code from hugetlb_cgroup_charge_cgroup() : (ERR_PTR(-ENOMEM)), so VM_FAULT_OOM is handled correctly. This is : consistent with failing mem cgroup charges in the non-hugetlb fault path. : : At the same time, restructure the return paths of alloc_huge_page() so it : is consistent. > > > It would be nice if you could add a comment over alloc_huge_page() > > explaining the return values (at least). Why sometimes ENOMEM, other > > times ENOSPC? > > > > The ENOSPC is used to specifically induce a VM_FAULT_SIGBUS, which > Documentation/vm/hugetlbfs_reserv.txt specifies is how faults are handled > if no hugetlb pages are available. That wasn't a code comment ;) Nobody will know to go looking in hugetlbfs_reserv.txt - it isn't even referred to from mm/*.c.