Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3249139ybt; Mon, 22 Jun 2020 19:53:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMviqCsVlBJ2lHVJr6YMy0Cuv83NbApTVB9x8MVqvqTShDKMdfFxF8NCMuM87CivBS31Uj X-Received: by 2002:a17:906:3905:: with SMTP id f5mr12530525eje.15.1592880823419; Mon, 22 Jun 2020 19:53:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592880823; cv=none; d=google.com; s=arc-20160816; b=fJDewQL9kb3BNz7Y0ck5uN01vQj5LyR/FDeS4eESqa1LPGqgfqARQNXVAWLtrg0OJi G+WqK2pvy0iaFmRT1UGmYBtw7lni7tgppxnEOHhNyP0K6z96e7EX3CFNF7Eo25JMLTaz OYdEpbyxPXxuBhbGrfG2QY9XjWH2fep04MATZdUD6PXONRie5ldpeJXkYQYw7PAP1VAJ IxlMPxsCw4jMKvxF499BgjD+i6uUWAxveaTsdXKta9CJAzVtbvHoisI3ahRxtYw1WGCp Vg6HFGKW4TffgiH4P0nUR+qQfVXtzUcsnEJv/GVmP9jba5zQwtCHUKkS2dChXqzJbC2t Gp6w== 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 :user-agent:message-id:in-reply-to:date:references:subject:cc:to :from:ironport-sdr:ironport-sdr; bh=XHd6KrTbQndOXFX2NEjC/etWPUZ7LS18S8SXuLvmjeE=; b=KBo34dAjRYEdRKpsQb1vaojUzvG7rV5BWUIxbZjXVu+p59KaiKkFONTIKo2E0DwNW1 qu9EMcMLIZvD8ysz8WfzWJvvSNrERMDxNhDkb5E6a6DCgQ0cI8DjBynTDU2RezNcYFRR CVsf1etyMCeq+yDFefGkACYBO9jeevMUaakRKM4F1/mpK5mv5rHCxspJyATknc3gR12l mMdU8Bt1H5PDCgbfbvuWIbNa2T/ys25am3y2QBzy/vus1NaR5YyP0zUNoJ4o1XMXOmNv tAUA9oSU6aVpnaq6HAKjmt2RpObq1E1voJtyS7C4JD9zLLvIUKyIiQZTprqnguRGo3zj rH1Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l1si9581728ejb.642.2020.06.22.19.53.20; Mon, 22 Jun 2020 19:53:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731833AbgFWCv3 (ORCPT + 99 others); Mon, 22 Jun 2020 22:51:29 -0400 Received: from mga03.intel.com ([134.134.136.65]:8474 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731434AbgFWCv3 (ORCPT ); Mon, 22 Jun 2020 22:51:29 -0400 IronPort-SDR: 4fbRkBhI0456nAQ2Bh7NG9bIu3yjvSMzVHIXGINkMdblffyF5QwuUh4Xsfw0xXUIFpbwy05fjw +XLsug8z7FCA== X-IronPort-AV: E=McAfee;i="6000,8403,9660"; a="143920307" X-IronPort-AV: E=Sophos;i="5.75,269,1589266800"; d="scan'208";a="143920307" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2020 19:51:27 -0700 IronPort-SDR: stMi4x4u0lGE9oF6INyqSIVVZASuHoTY6RLBNhZfKd1cGfjSj+eDTH/4My3zENuLBHRiWuxxoE C4MywkOnf8rQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,269,1589266800"; d="scan'208";a="275201085" Received: from yhuang-dev.sh.intel.com (HELO yhuang-dev) ([10.239.159.23]) by orsmga003.jf.intel.com with ESMTP; 22 Jun 2020 19:51:24 -0700 From: "Huang\, Ying" To: Ralph Campbell Cc: Yang Shi , John Hubbard , Zi Yan , , , Linux MM , , Linux Kernel Mailing List , Jerome Glisse , "Christoph Hellwig" , Jason Gunthorpe , Ben Skeggs , Andrew Morton , Shuah Khan Subject: Re: [PATCH 13/16] mm: support THP migration to device private memory References: <20200619215649.32297-1-rcampbell@nvidia.com> <20200619215649.32297-14-rcampbell@nvidia.com> <4C364E23-0716-4D59-85A1-0C293B86BC2C@nvidia.com> Date: Tue, 23 Jun 2020 10:51:23 +0800 In-Reply-To: (Ralph Campbell's message of "Mon, 22 Jun 2020 17:05:37 -0700") Message-ID: <87zh8uze8k.fsf@yhuang-dev.intel.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ralph Campbell writes: > On 6/22/20 4:54 PM, Yang Shi wrote: >> On Mon, Jun 22, 2020 at 4:02 PM John Hubbard wrote: >>> >>> On 2020-06-22 15:33, Yang Shi wrote: >>>> On Mon, Jun 22, 2020 at 3:30 PM Yang Shi wrote: >>>>> On Mon, Jun 22, 2020 at 2:53 PM Zi Yan wrote: >>>>>> On 22 Jun 2020, at 17:31, Ralph Campbell wrote: >>>>>>> On 6/22/20 1:10 PM, Zi Yan wrote: >>>>>>>> On 22 Jun 2020, at 15:36, Ralph Campbell wrote: >>>>>>>>> On 6/21/20 4:20 PM, Zi Yan wrote: >>>>>>>>>> On 19 Jun 2020, at 17:56, Ralph Campbell wrote: >>> ... >>>>>> Ying(cc’d) developed the code to swapout and swapin THP in one piece: https://lore.kernel.org/linux-mm/20181207054122.27822-1-ying.huang@intel.com/. >>>>>> I am not sure whether the patchset makes into mainstream or not. It could be a good technical reference >>>>>> for swapping in device private pages, although swapping in pages from disk and from device private >>>>>> memory are two different scenarios. >>>>>> >>>>>> Since the device private memory swapin impacts core mm performance, we might want to discuss your patches >>>>>> with more people, like the ones from Ying’s patchset, in the next version. >>>>> >>>>> I believe Ying will give you more insights about how THP swap works. >>>>> >>>>> But, IMHO device memory migration (migrate to system memory) seems >>>>> like THP CoW more than swap. >>> >>> >>> A fine point: overall, the desired behavior is "migrate", not CoW. >>> That's important. Migrate means that you don't leave a page behind, even >>> a read-only one. And that's exactly how device private migration is >>> specified. >>> >>> We should try to avoid any erosion of clarity here. Even if somehow >>> (really?) the underlying implementation calls this THP CoW, the actual >>> goal is to migrate pages over to the device (and back). >>> >>> >>>>> >>>>> When migrating in: >>>> >>>> Sorry for my fat finger, hit sent button inadvertently, let me finish here. >>>> >>>> When migrating in: >>>> >>>> - if THP is enabled: allocate THP, but need handle allocation >>>> failure by falling back to base page >>>> - if THP is disabled: fallback to base page >>>> >>> >>> OK, but *all* page entries (base and huge/large pages) need to be cleared, >>> when migrating to device memory, unless I'm really confused here. >>> So: not CoW. >> >> I realized the comment caused more confusion. I apologize for the >> confusion. Yes, the trigger condition for swap/migration and CoW are >> definitely different. Here I mean the fault handling part of migrating >> into system memory. >> >> Swap-in just needs to handle the base page case since THP swapin is >> not supported in upstream yet and the PMD is split in swap-out phase >> (see shrink_page_list). >> >> The patch adds THP migration support to device memory, but you need to >> handle migrate in (back to system memory) case correctly. The fault >> handling should look like THP CoW fault handling behavior (before >> 5.8): >> - if THP is enabled: allocate THP, fallback if allocation is failed >> - if THP is disabled: fallback to base page >> >> Swap fault handling doesn't look like the above. So, I said it seems >> like more THP CoW (fault handling part only before 5.8). I hope I >> articulate my mind. >> >> However, I didn't see such fallback is handled. It looks if THP >> allocation is failed, it just returns SIGBUS; and no check about THP >> status if I read the patches correctly. The THP might be disabled for >> the specific vma or system wide before migrating from device memory >> back to system memory. > > You are correct, the patch wasn't handling the fallback case. > I'll add that in the next version. For fallback, you need to split the THP in device firstly. Because you will migrate a base page instead a whole THP now. Best Regards, Huang, Ying >>> >>> thanks, >>> -- >>> John Hubbard >>> NVIDIA