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=-15.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 01E16C433DB for ; Wed, 27 Jan 2021 10:35:30 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 89F1120786 for ; Wed, 27 Jan 2021 10:35:29 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 89F1120786 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine 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 AF9C96B0006; Wed, 27 Jan 2021 05:35:28 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AA99A6B0008; Wed, 27 Jan 2021 05:35:28 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9BFBB6B000A; Wed, 27 Jan 2021 05:35:28 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0024.hostedemail.com [216.40.44.24]) by kanga.kvack.org (Postfix) with ESMTP id 8874C6B0006 for ; Wed, 27 Jan 2021 05:35:28 -0500 (EST) Received: from smtpin09.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 4D88D8249980 for ; Wed, 27 Jan 2021 10:35:28 +0000 (UTC) X-FDA: 77751198336.09.pest18_0f06ad527596 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin09.hostedemail.com (Postfix) with ESMTP id 307CE180AD802 for ; Wed, 27 Jan 2021 10:35:28 +0000 (UTC) X-HE-Tag: pest18_0f06ad527596 X-Filterd-Recvd-Size: 4221 Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by imf50.hostedemail.com (Postfix) with ESMTP for ; Wed, 27 Jan 2021 10:35:27 +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=1611743726; h=from:from:reply-to: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=JlSBFLP0Vb+8qVldB0gSKtEyWNeUb6Om2JuiscXD3Qk=; b=MalpUyJsEln1nVRHCCjqCaOro/dqNbxdcHyN1WVShqunXnlqQI1NA5dYYJJ9Pzx+NoBL9C moYK0bw7J1xNOTtdfvI+yY8FDtLJihiVjlMvEdBBrLQZRs3ix4LTr+gxIMmv4RyBNujYsK VO3SAUlRCMAfj3DceUwfp0CiPHtJmLc= Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 8F60FADA2; Wed, 27 Jan 2021 10:35:26 +0000 (UTC) Date: Wed, 27 Jan 2021 11:35:23 +0100 From: Michal Hocko To: Mike Kravetz Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Naoya Horiguchi , Muchun Song , David Hildenbrand , Oscar Salvador , Matthew Wilcox , Miaohe Lin , Andrew Morton Subject: Re: [PATCH v3 3/5] hugetlb: only set HPageMigratable for migratable hstates Message-ID: <20210127103523.GI827@dhcp22.suse.cz> References: <20210122195231.324857-1-mike.kravetz@oracle.com> <20210122195231.324857-4-mike.kravetz@oracle.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210122195231.324857-4-mike.kravetz@oracle.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 Fri 22-01-21 11:52:29, Mike Kravetz wrote: > The HP_Migratable flag indicates a page is a candidate for migration. > Only set the flag if the page's hstate supports migration. This allows > the migration paths to detect non-migratable pages earlier. If migration > is not supported for the hstate, HP_Migratable will not be set, the page > will not be isolated and no attempt will be made to migrate. We should > never get to unmap_and_move_huge_page for a page where migration is not > supported, so throw a warning if we do. > > Signed-off-by: Mike Kravetz > --- > fs/hugetlbfs/inode.c | 2 +- > include/linux/hugetlb.h | 9 +++++++++ > mm/hugetlb.c | 8 ++++---- > mm/migrate.c | 9 ++++----- > 4 files changed, 18 insertions(+), 10 deletions(-) > > diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c > index e1d7ed2a53a9..93f7b8d3c5fd 100644 > --- a/fs/hugetlbfs/inode.c > +++ b/fs/hugetlbfs/inode.c > @@ -735,7 +735,7 @@ static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset, > > mutex_unlock(&hugetlb_fault_mutex_table[hash]); > > - SetHPageMigratable(page); > + SetHPageMigratableIfSupported(page); > /* > * unlock_page because locked by add_to_page_cache() > * put_page() due to reference from alloc_huge_page() > diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h > index 58be44a915d1..cd1960541f2a 100644 > --- a/include/linux/hugetlb.h > +++ b/include/linux/hugetlb.h > @@ -740,6 +740,15 @@ static inline bool hugepage_migration_supported(struct hstate *h) > return arch_hugetlb_migration_supported(h); > } > > +/* > + * Only set HPageMigratable if migration supported for page > + */ > +static inline void SetHPageMigratableIfSupported(struct page *page) This is really mouthful... > +{ > + if (hugepage_migration_supported(page_hstate(page))) > + SetHPageMigratable(page); and it is really a trivial wrapper. I do understand why you want to prevent from the code duplication and potentially a missing check but this all is just an internal hugetlb code. Even if the flag is set on non-migrateable hugetlb page then this will not be fatal. The migration can fail even on those pages for which migration is supported right? So I am not really sure this is an improvement in the end. But up to you I do not really have a strong opinion here. -- Michal Hocko SUSE Labs