Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2402768ybl; Mon, 20 Jan 2020 02:13:33 -0800 (PST) X-Google-Smtp-Source: APXvYqxM4BZVSgPBL/1tFV+740yFQA7uSIIeGeeeRxp/6sINxVbkWxjrRGMvf7a1BHdwEolNaphK X-Received: by 2002:a9d:3b23:: with SMTP id z32mr14858906otb.159.1579515213039; Mon, 20 Jan 2020 02:13:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579515213; cv=none; d=google.com; s=arc-20160816; b=zUOzJ6IppO5CM3suawUFAwwFt0VO8sjDmwiPoR/GS5FDBz2RsyXYNpN7FhcggHCLor nKOr2T0881xCVjejpdbrvp/Ex5/0OJdaDRnX467g4xFlFVDdqHwSMoA046mVR/whI8MQ yVJVhqtZuDKyAlkq7twbOzp43T6E9o9IX8jXysR/tlKUgaBFkeT1lReIGvXdkjTpzp+C xfdPe6TIX2HG9kxnZ6rL2dNJG1/AZNarwQEAA5P608CE1nejeUdDSV6DSdoOHQSJ/o3V 95BP/Yc+yX3Gk/alqEl0FCNuFHjRV6tH/n1SqseiqyfKvsopNKOIdXgzUpR+JfaSindE KJfg== 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-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=adbdjiVau9etS2t3ssB2A258KBgSziRfDhmtS4rPNeg=; b=w4Zd39ARartjgKkTQ6qsWpTao1ZDL8aiwHnk2pe4/DRWZZ24oCMK1nWyQ+5/NcJJi1 eO9qKBITVzw+jrPPpIRZUoe9kd+GHAppUeQXa+vtI4hYBA9BnQHgEp+sp+BRqeb05asn Ub7TGMil3kP8a9sgIGB7DVX1PQpGJh0G4QyMKP0Z/TojATl7iRGp2mpsshDpfevejiFt roQG3DCKam8d4sX1GLAH/tPtcjCTbhNIYIq7yGJEuHnzBNmrQfOb8G+bifUYbkIaoDXT XhIZ8cWUBjAsb1Hz20t/k23jdciYthTL20HzMPoLamlRHv3z8qYGizjybdwx7w0Em5RY TmcA== 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 n18si20892463otf.285.2020.01.20.02.13.20; Mon, 20 Jan 2020 02:13:33 -0800 (PST) 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 S1726901AbgATKMH (ORCPT + 99 others); Mon, 20 Jan 2020 05:12:07 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:37257 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726626AbgATKMH (ORCPT ); Mon, 20 Jan 2020 05:12:07 -0500 Received: by mail-wr1-f66.google.com with SMTP id w15so28925521wru.4 for ; Mon, 20 Jan 2020 02:12:04 -0800 (PST) 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:content-transfer-encoding :in-reply-to:user-agent; bh=adbdjiVau9etS2t3ssB2A258KBgSziRfDhmtS4rPNeg=; b=E9J9CtpzBiyvN4K0Q0eX/BXDwJXv5DtNjB9TcU9U5WqWOdtnhl0nPw64eym1CBNNct iG/+rfDRErgoz6m09FX9OyeuOPq0aQ1RKzOA5GUFd3jZnvGqxB/Iha2S7HuOCs/Gj7Uh vxSiH29xS8hmO61s/7AsWH3qQazbgn5tlLfUwAcSy4rtnqzHwNRz2gAzBF4uJH8u1VSm N8pInsolBGMeOYC3EMWIFlQuxaMv17c3zGyKkpmE/idmJs3YRDyiAeKesDa+955vzx+/ +DN4i4FAiae9EIcAQsrBpTIaYvDuReKImDkaInLi8q1XHmCunzU/NNGlV2aSTFa7GI9I 9iAA== X-Gm-Message-State: APjAAAUxvrdx8fOf45EmhW+AmfDlRDDDq9p49Gm7tWzhhOkfrgRhcv9v 3uDfIBGQaiSQAoupv6nthNpEWIY3 X-Received: by 2002:adf:fa12:: with SMTP id m18mr17148681wrr.309.1579515124093; Mon, 20 Jan 2020 02:12:04 -0800 (PST) Received: from localhost (prg-ext-pat.suse.com. [213.151.95.130]) by smtp.gmail.com with ESMTPSA id p26sm21404509wmc.24.2020.01.20.02.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Jan 2020 02:12:03 -0800 (PST) Date: Mon, 20 Jan 2020 11:12:02 +0100 From: Michal Hocko To: Li Xinhai Cc: "linux-mm@kvack.org" , akpm , torvalds , "linux-kernel@vger.kernel.org" , Mike Kravetz Subject: Re: [PATCH v4] mm/mempolicy,hugetlb: Checking hstate for hugetlbfs page in vma_migratable Message-ID: <20200120101202.GU18451@dhcp22.suse.cz> References: <1579147885-23511-1-git-send-email-lixinhai.lxh@gmail.com> <20200116095614.GO19428@dhcp22.suse.cz> <20200116215032206994102@gmail.com> <20200116151803.GV19428@dhcp22.suse.cz> <20200116233817972969139@gmail.com> <20200117111629898234212@gmail.com> <20200118111121432688303@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200118111121432688303@gmail.com> User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat 18-01-20 11:11:23, Li Xinhai wrote: > On 2020-01-17?at 11:16?Li Xinhai?wrote: > >On 2020-01-16?at 23:38?Li Xinhai?wrote: > >>On 2020-01-16?at 23:18?Michal Hocko?wrote: > >>>On Thu 16-01-20 21:50:34, Li Xinhai wrote: > >>>> On 2020-01-16?at 17:56?Michal Hocko?wrote: > >>>> >On Thu 16-01-20 04:11:25, Li Xinhai wrote: > >>>> >> Checking hstate at early phase when isolating page, instead of during > >>>> >> unmap and move phase, to avoid useless isolation. > >>>> > > >>>> >Could you be more specific what you mean by isolation and why does it > >>>> >matter? The patch description should really explain _why_ the change is > >>>> >needed or desirable. > >>>> > >>>> The changelog can be improved: > >>>> > >>>> vma_migratable() is called to check if pages in vma can be migrated > >>>> before go ahead to isolate, unmap and move pages. For hugetlb pages, > >>>> hugepage_migration_supported(struct hstate *h) is one factor which > >>>> decide if migration is supported. In current code, this function is called > >>>> from?unmap_and_move_huge_page(), after isolating page has > >>>> completed. > >>>> This patch checks hstate from vma_migratable() and avoids isolating pages > >>>> which are not supported. > >>> > >>>This still explains what but not why this is relevant. If by isolating > >>>pages you mean isolate_lru_page then this really a noop for hugetlb > >>>pages. Or do I still misread your changelog? > >> > >>I mean?isolate_huge_page will queue pages for moving, and > >>unmap_and_move_huge_page will call > >>hugepage_migration_supported then refuse moving. > >> > > > >Forgot to mention that this patch has no relevant with this one > >https://patchwork.kernel.org/patch/11331639/,? > > > >Code change at here is common for avoids walking page table and > >isolate hugepage in case architecture or page size are not supported > >for migration. Comments from code are copied here: > > > >static int unmap_and_move_huge_page(...) > >{ > > /* > > * Migratability of hugepages depends on architectures and their size. > > * This check is necessary because some callers of hugepage migration > > * like soft offline and memory hotremove don't walk through page > > * tables or check whether the hugepage is pmd-based or not before > > * kicking migration. > > */ > > if (!hugepage_migration_supported(page_hstate(hpage))) { > > putback_active_hugepage(hpage); > > return -ENOSYS; > > } > >} > > > >For current code change, we are able to know the 'hstate' because we have 'vma', so > >do early check instead of later. > > > > https://lore.kernel.org/linux-mm/20200117111629898234212@gmail.com/ > > Revise with more details on changelog for reason why this patch > is need. Thanks for your comments. > > --- > vma_migratable() is called to check if pages in vma can be migrated > before go ahead to further actions. Currently it is used in below code > path: > - task_numa_work (kernel\sched\fair.c) > - mbind (mm\mempolicy.c) > - move_pages (mm\migrate.c) > > For hugetlb mapping, vma is migratable or not is determined by: > - CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION > - arch_hugetlb_migration_supported > > Issue: current code only checks for CONFIG_ARCH_ENABLE_HUGEPAGE_MIGRATION. Explain why this is an issue. Because as things stand now this doesn't cause any problems at all. All architectures simply support migrating all hugetlb sizes AFAIK. If this is not the case then mention which of them are not. > This patch checks the two factors to impove code logic. Besides, caller > of vma_migratable can take action properly in case architecture don't > support migration, e.g., mbind don't go further to try isolating/moving > pages, but currently it do continue because vma_migratable say yes. I do not follow. What are you trying to say here? The changelog should be explicit it doesn't really fix any existing problem. And the whole purpose is a code robustness cleanup. Should we ever have an architecture that doesn't support all hugetlb sizes then we would safe pointless huge page isolation for a page that cannot be migrated in the first place. See how the above actually explains _why_ you want to make the change? > No adding for Fix tag, since vma_migratable was implemented before > arch_hugetlb_migration_supported, it is up to the caller to use it. This is also of no relevance. -- Michal Hocko SUSE Labs