Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp7278645imm; Tue, 28 Aug 2018 09:12:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZDXswpkWH2LPlK7Uk8In7XIR8yDZDlwJ5wCKd/YVwx5XNEyhwss0Ks2adADBE7XP/2KWPM X-Received: by 2002:a63:cb0f:: with SMTP id p15-v6mr2220428pgg.197.1535472753327; Tue, 28 Aug 2018 09:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535472753; cv=none; d=google.com; s=arc-20160816; b=LhBa3FYfbsxC74z1SSxsXOdwS2xppXHcU4wNpdEyHbgDe9MkdwpKiRrazIEoCZ1iqV dVorN1Y2hLFXz02mtRejvWbTuxTwu3nSwlbK+2vk/bGBdsrR3BBXsgBQdL6wsuBugOml tcgPb4UruuGXoF6xqv0jTpEaBCGQtdTuGUqPRyx9njICCIeJi+1/zncVgOM/HW4aKY5F giev2JH+LnufTLdxBLLeCewFF4HCNlEWdul0gkDd+iAUJQsNvGqXBqgE5VA4k+HXtlda keSofV3XiYoh/z6lobbm/BKTo5ZlV9qUuD6C+i4n7AZSPd2QD25vk/yKigvq5Io6/Tux 5F+g== 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:arc-authentication-results; bh=Afw3+xMLPeFlSpn5lrG4v4A73fTO0w9tJSDF3TXfs5A=; b=c5pkdDDxTeUg9lGW9HTXQcdnXoliJqB55+PZl9ukQ8a1/kZzFY/SwHfedEg5wOTaOh fFDsQDwxi9mBIz57yhby6RqtFgb4MElRtb230JbA9fNM9FphKsMWZT/4sjpZdW6wDnZb UvlV00B78KK7Pt7wvEodfVz4vXXkfISuLKEsTLx491bq4mkJVakL446fYBt74vYMj4vk /4SrNjYsFJFmcNsbmYkfweQeYIH3DSpMLq0CFl6xUYMNclr29MxSVGsZamYlEZpjeeiN kwCGJiVD+YYbxFZaKcXoC1szhoZP+sbkIl97OuK4li4CpmhsbI7jgQWQUCmMCbcDjyQa Qw+g== 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 p82-v6si1308941pfi.345.2018.08.28.09.12.17; Tue, 28 Aug 2018 09:12:33 -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 S1727368AbeH1UDI (ORCPT + 99 others); Tue, 28 Aug 2018 16:03:08 -0400 Received: from mx2.suse.de ([195.135.220.15]:33952 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727069AbeH1UDI (ORCPT ); Tue, 28 Aug 2018 16:03:08 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id AA61CADA9; Tue, 28 Aug 2018 16:10:44 +0000 (UTC) Date: Tue, 28 Aug 2018 18:10:43 +0200 From: Michal Hocko To: Zi Yan Cc: Jerome Glisse , linux-mm@kvack.org, Andrew Morton , linux-kernel@vger.kernel.org, "Aneesh Kumar K . V" , Ralph Campbell , John Hubbard Subject: Re: [PATCH 4/7] mm/hmm: properly handle migration pmd Message-ID: <20180828161043.GT10223@dhcp22.suse.cz> References: <20180824192549.30844-1-jglisse@redhat.com> <20180824192549.30844-5-jglisse@redhat.com> <0560A126-680A-4BAE-8303-F1AB34BE4BA5@cs.rutgers.edu> <20180828152414.GQ10223@dhcp22.suse.cz> <20180828153658.GA4029@redhat.com> <20180828154206.GR10223@dhcp22.suse.cz> <20180828154555.GS10223@dhcp22.suse.cz> <44C89854-FE83-492F-B6BB-CF54B77233CF@cs.rutgers.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <44C89854-FE83-492F-B6BB-CF54B77233CF@cs.rutgers.edu> 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 Tue 28-08-18 11:54:33, Zi Yan wrote: > Hi Michal, > > On 28 Aug 2018, at 11:45, Michal Hocko wrote: > > > On Tue 28-08-18 17:42:06, Michal Hocko wrote: > >> On Tue 28-08-18 11:36:59, Jerome Glisse wrote: > >>> On Tue, Aug 28, 2018 at 05:24:14PM +0200, Michal Hocko wrote: > >>>> On Fri 24-08-18 20:05:46, Zi Yan wrote: > >>>> [...] > >>>>>> + if (!pmd_present(pmd)) { > >>>>>> + swp_entry_t entry = pmd_to_swp_entry(pmd); > >>>>>> + > >>>>>> + if (is_migration_entry(entry)) { > >>>>> > >>>>> I think you should check thp_migration_supported() here, since PMD migration is only enabled in x86_64 systems. > >>>>> Other architectures should treat PMD migration entries as bad. > >>>> > >>>> How can we have a migration pmd entry when the migration is not > >>>> supported? > >>> > >>> Not sure i follow here, migration can happen anywhere (assuming > >>> that something like compaction is active or numa or ...). So this > >>> code can face pmd migration entry on architecture that support > >>> it. What is missing here is thp_migration_supported() call to > >>> protect the is_migration_entry() to avoid false positive on arch > >>> which do not support thp migration. > >> > >> I mean that architectures which do not support THP migration shouldn't > >> ever see any migration entry. So is_migration_entry should be always > >> false. Or do I miss something? > > > > And just to be clear. thp_migration_supported should be checked only > > when we actually _do_ the migration or evaluate migratability of the > > page. We definitely do want to sprinkle this check to all places where > > is_migration_entry is checked. > > is_migration_entry() is a general check for swp_entry_t, so it can return > true even if THP migration is not enabled. is_pmd_migration_entry() always > returns false when THP migration is not enabled. > > So the code can be changed in two ways, either replacing is_migration_entry() > with is_pmd_migration_entry() or adding thp_migration_supported() check > like Jerome did. > > Does this clarify your question? Not really. IIUC the code checks for the pmd. So even though is_migration_entry is a more generic check it should never return true for thp_migration_supported() == F because we simply never have those unless I am missing something. is_pmd_migration_entry is much more readable of course and I suspect it can save few cycles as well. -- Michal Hocko SUSE Labs