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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB1A6C77B7D for ; Mon, 8 May 2023 03:02:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232513AbjEHDB4 (ORCPT ); Sun, 7 May 2023 23:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231836AbjEHDAp (ORCPT ); Sun, 7 May 2023 23:00:45 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DB0457EE4 for ; Sun, 7 May 2023 19:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1683514793; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hf0y8biX1fmWFzJdwC/6/gmCOXFL3ymrq+8iff3P/gA=; b=FXueB92N4oF11Y1CYCefgt5ZW3WAp/ONdN5y7pYZqFWQjXskGVkOlZIINOZKzO4Icd8ffB 6urzkFyImcQNWshLPLN9cVv/24XfD2OlhWXYnsRUEDEWLpPGF23yaj3IpHaiB1qDIw/oD/ +jx0rLqTrJvaoEVZkoQKcXHOdI23EOg= Received: from mail-lj1-f198.google.com (mail-lj1-f198.google.com [209.85.208.198]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-461-0oyq4yv8MVqacQzqYNBB-Q-1; Sun, 07 May 2023 22:59:51 -0400 X-MC-Unique: 0oyq4yv8MVqacQzqYNBB-Q-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2ad93fa7132so2258571fa.0 for ; Sun, 07 May 2023 19:59:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683514790; x=1686106790; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=hf0y8biX1fmWFzJdwC/6/gmCOXFL3ymrq+8iff3P/gA=; b=c+D4ouzT+Z7Cpvf3azilrQMEXxuz+Mg6pVSBVzA4Kv8VXSwVp9H9qDhlbxgkG7naqe /F9LKzbDYsttmbD18YhAKh4ggO4iiXS+ytEUzZB/zFlrFJVVLClqOC51dOZ8ZND6fOga cZ5qaAr4iqqBrOabD6HP0fysmlGpnEDwWkWs5toqMuwkCXsig5vueckwKh0Lnajchj4q QuPrWGV15DQh9eftvBbUMrGKf0S4Mno3zWFCHGDfbH0K5tOy14eJ0w6z1D3JHVp3Yvy1 qh5hd3FAsv+cC5eTP9eRWkeWYReV7Fk33Brkf+wZ6dSMcFWs2rhRDsP+7NLZL+JYV0o+ mtzA== X-Gm-Message-State: AC+VfDyLg5mXTrsiriDKl20si3gghn1ALttyNd0EzwbszCZosJjJW082 wMDfFoC8V/2sB70R+1nKgssq+uVro18O8TKFBGxmyUHHiFuXSB1vPXf9fajHdR9f2OBhNhROTpT AH7XOp2LcQq4btePG7C6JYWQ= X-Received: by 2002:ac2:548f:0:b0:4ea:fabb:4db1 with SMTP id t15-20020ac2548f000000b004eafabb4db1mr2061462lfk.1.1683514790281; Sun, 07 May 2023 19:59:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5JxCpWUmBpdpbkhI6qHC3tfE841A1miI1aAw8ej/Hti23WwvWnwBjH/zfGx5yEpi+SOjHlcg== X-Received: by 2002:ac2:548f:0:b0:4ea:fabb:4db1 with SMTP id t15-20020ac2548f000000b004eafabb4db1mr2061455lfk.1.1683514789992; Sun, 07 May 2023 19:59:49 -0700 (PDT) Received: from [192.168.1.121] (85-23-48-202.bb.dnainternet.fi. [85.23.48.202]) by smtp.gmail.com with ESMTPSA id t21-20020ac24c15000000b004cc8196a308sm1136305lfq.98.2023.05.07.19.59.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 07 May 2023 19:59:49 -0700 (PDT) Message-ID: Date: Mon, 8 May 2023 05:59:46 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] mm/migrate_device: Try to handle swapcache pages. Content-Language: en-US To: "Huang, Ying" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, apopple@nvidia.com, jhubbard@nvidia.com, rcampbell@nvidia.com References: <20230507061726.13422-1-mpenttil@redhat.com> <87wn1ja793.fsf@yhuang6-desk2.ccr.corp.intel.com> From: =?UTF-8?Q?Mika_Penttil=c3=a4?= In-Reply-To: <87wn1ja793.fsf@yhuang6-desk2.ccr.corp.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org H, On 8.5.2023 5.26, Huang, Ying wrote: > mpenttil@redhat.com writes: > >> From: Mika Penttilä >> >> Migrating file pages and swapcache pages into device memory is not supported. >> The decision is done based on page_mapping(). For now, swapcache pages are not migrated. >> >> Things can however be improved, for swapcache pages. Try to get rid of the swap cache, >> and if successful, go ahead as with other anonymous pages. >> >> As a detail, do not mess with shmem pages, as they handle swap internally. >> >> Cc: Alistair Popple >> Cc: John Hubbard >> Cc: Ralph Campbell >> Signed-off-by: Mika Penttilä >> --- >> mm/migrate_device.c | 12 ++++++++++-- >> 1 file changed, 10 insertions(+), 2 deletions(-) >> >> diff --git a/mm/migrate_device.c b/mm/migrate_device.c >> index d30c9de60b0d..e8169c58c341 100644 >> --- a/mm/migrate_device.c >> +++ b/mm/migrate_device.c >> @@ -12,6 +12,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -750,10 +751,17 @@ static void __migrate_device_pages(unsigned long *src_pfns, >> /* >> * For now only support anonymous memory migrating to >> * device private or coherent memory. >> + * >> + * Try to get rid of swap cache if possible. >> + * Leave shmem pages alone, they handle swap internally >> + * >> */ >> if (mapping) { >> - src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; >> - continue; >> + if (shmem_mapping(mapping) || >> + !folio_free_swap(page_folio(page))) { > > Should we filter out file pages firstly? folio_free_swap() checks first and returns false if not swapcache page (ie including normal file pages) so think that is enough, but maybe for clarity and not depending on it, could be good explicitly check for swapcache before calling folio_free_swap(). > >> + src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; >> + continue; >> + } >> } >> } else if (is_zone_device_page(newpage)) { >> /* > > Best Regards, > Huang, Ying > Thanks, Mika