Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp3957794ybi; Tue, 18 Jun 2019 09:13:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyDBHAeAOueuAL69+USy7u1wSznvk/XBru37AJOpEZqm4nUKXCc3QEreq/03qGbSLWxYQDW X-Received: by 2002:a17:90a:1785:: with SMTP id q5mr5934350pja.106.1560874392295; Tue, 18 Jun 2019 09:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560874392; cv=none; d=google.com; s=arc-20160816; b=Yey1MYP7M5/lGAKDWJwFMdpHSdSP6o8Q7W46ZmLnqaPrmLojpvHB4k1Nzjh/YzgmTY NkoLkUIDCZrHZ9rVv/J17kI1C2TJnv5dTKJvu1AihSMzJa8eer5IMmHocsyAYeVdIudE uIv7MbucL1KSMnR4k0HLX2gzL+lGNf+K0ENadkkr+0oR9CAgghOo78fquiZLW2ud4pOq p9Nw8mqPM0isC8wcMrav7rmbHd9KT0bJ7DamXDBs/KmeNzhQ55PT43Js8naLfxUfcqXB 6FQmSaC8t2HyswtxY1mGKBBl5ovJ6STKvUByxAmoTk6sI0ug4FXrlIx9arisqAgn2Tnf ab9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=oITxGW1LHubvM44T0Ldv0yFOUtOoUW2OSbAxzFTO8fE=; b=CDkxc1FBvhXab143Xs4EgzH2tcI2diLSdjUi10OVxFTzFhWDSTJHdRgQ6h4o699Ya0 05kLIEONeNxQCNSSQ5XbtzHFP5eCLU1sWinc7RLyvq4T+VtFvPKHxCBES0PDVJ1dERdt ZMXTJ7E4WB00gHe2/7jqK7dJDn4i4vLZLrs0dmjoUnba86qcInJkcJ1Ce2tCF+uY8Bc3 b+Fv/B7iuiBnDue41juSQ92XtNUaziq56OpiPkx27Rhfmj9Rbw3DgVLgk5R5l5cA/62Y PNShKWcsj4yCxE59bQsUAL2AOd3Hdn67J1Yl0U9ylopr3GBSaIltTLHBAdBEnoGHULch fuNQ== 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 a17si6792248pfk.246.2019.06.18.09.12.56; Tue, 18 Jun 2019 09:13:12 -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 S1729877AbfFRQL4 (ORCPT + 99 others); Tue, 18 Jun 2019 12:11:56 -0400 Received: from mx2.suse.de ([195.135.220.15]:55994 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729272AbfFRQLz (ORCPT ); Tue, 18 Jun 2019 12:11:55 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 88853AEE0; Tue, 18 Jun 2019 16:11:54 +0000 (UTC) Date: Tue, 18 Jun 2019 18:11:51 +0200 From: Oscar Salvador To: Naoya Horiguchi Cc: linux-mm@kvack.org, Andrew Morton , Michal Hocko , Mike Kravetz , xishi.qiuxishi@alibaba-inc.com, "Chen, Jerry T" , "Zhuo, Qiuxu" , linux-kernel@vger.kernel.org, Anshuman Khandual Subject: Re: [PATCH v3 2/2] mm: hugetlb: soft-offline: dissolve_free_huge_page() return zero on !PageHuge Message-ID: <20190618161151.GB14817@linux> References: <1560761476-4651-1-git-send-email-n-horiguchi@ah.jp.nec.com> <1560761476-4651-3-git-send-email-n-horiguchi@ah.jp.nec.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1560761476-4651-3-git-send-email-n-horiguchi@ah.jp.nec.com> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jun 17, 2019 at 05:51:16PM +0900, Naoya Horiguchi wrote: > madvise(MADV_SOFT_OFFLINE) often returns -EBUSY when calling soft offline > for hugepages with overcommitting enabled. That was caused by the suboptimal > code in current soft-offline code. See the following part: > > ret = migrate_pages(&pagelist, new_page, NULL, MPOL_MF_MOVE_ALL, > MIGRATE_SYNC, MR_MEMORY_FAILURE); > if (ret) { > ... > } else { > /* > * We set PG_hwpoison only when the migration source hugepage > * was successfully dissolved, because otherwise hwpoisoned > * hugepage remains on free hugepage list, then userspace will > * find it as SIGBUS by allocation failure. That's not expected > * in soft-offlining. > */ > ret = dissolve_free_huge_page(page); > if (!ret) { > if (set_hwpoison_free_buddy_page(page)) > num_poisoned_pages_inc(); > } > } > return ret; Hi Naoya, just a nit: > > Here dissolve_free_huge_page() returns -EBUSY if the migration source page > was freed into buddy in migrate_pages(), but even in that case we actually > has a chance that set_hwpoison_free_buddy_page() succeeds. So that means > current code gives up offlining too early now. Maybe it is me that I am not really familiar with hugetlb code, but having had a comment pointing out that the releasing of overcommited hugetlb pages into the buddy allocator happens in migrate_pages()->put_page()->free_huge_page() would have been great. > > dissolve_free_huge_page() checks that a given hugepage is suitable for > dissolving, where we should return success for !PageHuge() case because > the given hugepage is considered as already dissolved. > > This change also affects other callers of dissolve_free_huge_page(), > which are cleaned up together. > > Reported-by: Chen, Jerry T > Tested-by: Chen, Jerry T > Signed-off-by: Naoya Horiguchi > Fixes: 6bc9b56433b76 ("mm: fix race on soft-offlining") > Cc: # v4.19+ Reviewed-by: Oscar Salvador -- Oscar Salvador SUSE L3