From patchwork Wed May 31 04:40:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Mika_Penttil=C3=A4?= X-Patchwork-Id: 13261478 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E5749C77B7C for ; Wed, 31 May 2023 04:41:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5FDD0900002; Wed, 31 May 2023 00:41:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5AD4F6B0074; Wed, 31 May 2023 00:41:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47551900002; Wed, 31 May 2023 00:41:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 387F16B0072 for ; Wed, 31 May 2023 00:41:26 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 032F0A0169 for ; Wed, 31 May 2023 04:41:25 +0000 (UTC) X-FDA: 80849301372.29.55F91B3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 1325040015 for ; Wed, 31 May 2023 04:41:22 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OhLByWk8; spf=pass (imf07.hostedemail.com: domain of mpenttil@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mpenttil@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685508083; a=rsa-sha256; cv=none; b=8ErvDxf7qq3WiAqcWwrwWp9JfJWN4jYWeq0UBganxjTnweuQ/xZt8dc57WggA8zcpXY/3S 44zx3HxSiXMAweuZ3RAnD9/XJjEOI8Kq80/LgCjjL8RYRz6O2JXYDDGVITTBiuzFJbEjgu D5TJ0bZeNcp/IBocipZPEGfD0oWPrZw= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OhLByWk8; spf=pass (imf07.hostedemail.com: domain of mpenttil@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mpenttil@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685508083; h=from:from:sender: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: references:dkim-signature; bh=UYEFrarq5y6NtgfnLcdtrjWHlHd0aEmEkiPetBxugj8=; b=pztggQu1lLrF/BPJnA4SwwzKr4POPMG3pQK0JTkI1ki/T88i3ik9h3eOBi9gTUR9xNGmLZ pZM8E3twJ4je9Tit1mPOUNWY/C2Vyv5MRIT7tpRSxh80Bu52C6hM0NaoJlRPCX6sCLjVSp Rogi9mVtVR9CJjILHeGk1jwpoK7Jeec= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685508082; 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; bh=UYEFrarq5y6NtgfnLcdtrjWHlHd0aEmEkiPetBxugj8=; b=OhLByWk8hSpVsg9gd/+Xc1FRaRpIWIf0CExOVr8iQrB0kcsQwt9VPWK2H2Cu8X7siDcpKK j2Sek5nCVeSzjCZFyEYK4LF59I9/DW5G784WlHoOEDObAdwD+gfJpqu6FlES/DErLc3tg7 fTddiKP0/2OeWdS5ueSTNuqOS363+bk= Received: from mail-lf1-f69.google.com (mail-lf1-f69.google.com [209.85.167.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-358-NxSGfyGlPe62doeGZ7l2zQ-1; Wed, 31 May 2023 00:41:20 -0400 X-MC-Unique: NxSGfyGlPe62doeGZ7l2zQ-1 Received: by mail-lf1-f69.google.com with SMTP id 2adb3069b0e04-4f3a517b5c6so305420e87.0 for ; Tue, 30 May 2023 21:41:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685508078; x=1688100078; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=UYEFrarq5y6NtgfnLcdtrjWHlHd0aEmEkiPetBxugj8=; b=BmKZEsQPxeF1TQLqdFsjVZWTnI3/euex3qNJoozNtANa0UvsUyzxhUPPbTgIF4x0uN zdqOKOAjyZPI9UyxlDYmbN2UR4OFCPayoKQUO/+el5f7TiGnR3SQYp819TSEmMcL0Hbz 5tC2gblTuJj4vaYmhU6IVRd6HTOkJ0lsOPnB9hExYQmQCitno7IwoptE66QAm+O93ae+ DqrwFOhkWNUo2wrSLlfj+Z1kOJv+BzN5LcamQ9UDGbFy9f/e+C5jupxuZYk2ES9gwobp 23JKVmjwgeJWjR+MBHVKkPn96hMxowGZ5qqtwjxbEBpJWo1fQJznPsNVzmDUOI4pooxt pSxQ== X-Gm-Message-State: AC+VfDzcyqEXgIXhp+UUJco6VgLzbMPrq62o+xyqC3czUIhhuByFC3Gu QfGFmT8caWG5IcAcnTBH6msHlqQHdhOR8LoJ7QBJ3UFeUdfJUnhn4H8+hXEw7xirre45qa35pE3 NoNUQXQDXjQ== X-Received: by 2002:a05:6512:31d6:b0:4f4:f38a:4423 with SMTP id j22-20020a05651231d600b004f4f38a4423mr4415692lfe.27.1685508078615; Tue, 30 May 2023 21:41:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6V0NcpagTYTWBJxBDh7faQPnfd0NUxubPvmUPnnIZthRTkB0B6uC0Tku8OOzlnqMU/pj6SGA== X-Received: by 2002:a05:6512:31d6:b0:4f4:f38a:4423 with SMTP id j22-20020a05651231d600b004f4f38a4423mr4415690lfe.27.1685508078341; Tue, 30 May 2023 21:41:18 -0700 (PDT) Received: from mjp-Z390-AORUS-MASTER.redhat.com (85-23-48-202.bb.dnainternet.fi. [85.23.48.202]) by smtp.gmail.com with ESMTPSA id p24-20020ac246d8000000b004ec84d24818sm555088lfo.282.2023.05.30.21.41.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 May 2023 21:41:17 -0700 (PDT) From: mpenttil@redhat.com To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: =?utf-8?q?Mika_Penttil=C3=A4?= , Alistair Popple , John Hubbard , Ralph Campbell , Huang Ying Subject: [PATCH v2] mm/migrate_device: Try to handle swapcache pages Date: Wed, 31 May 2023 07:40:18 +0300 Message-Id: <20230531044018.17893-1-mpenttil@redhat.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 1325040015 X-Stat-Signature: w6mw3754xba97ftqk7xqhg547wconf6r X-Rspam-User: X-HE-Tag: 1685508082-649084 X-HE-Meta: U2FsdGVkX1/dLssdfI9Wgf8Vn9sq4pQbiigcRcvS+QCj92h1sn+KzYQNa4kNtXGAJQDABn02VesRMFkk9dMDMUoDdOjiyqWwSjLe4SXEHJScAo6UssCwW+iSd3RsXiWGklxD3JcYYKYiGnYulPSCxBQVgd1gBp4cwdAeB1csJP922Pj6lTwUbZqoJPpKM5nTKza/TbFE1lTLAL3+yKX81Yk2IEd0EvS5P53IpR28uoI5v4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au3o0ByjLU/EmUzLRfzZ0J4iqUmOXOjOtHucQs46HnO7HX/qcUpH0lR9hmtq9nxX3PVKSXu3med8TycQQsGEi/P8h8Vi2gG02xebybBQcXz7zy5OC18gmnGkPqLuNM1dAgb6zqtIC9ynFFVzfDuZVyNZzlXlUknR 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: 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. Cc: Alistair Popple Cc: John Hubbard Cc: Ralph Campbell Cc: Huang Ying Signed-off-by: Mika Penttilä Reviewed-by: "Huang, Ying" --- v2: - use folio_test_anon() (Huang, Ying) mm/migrate_device.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/mm/migrate_device.c b/mm/migrate_device.c index d30c9de60b0d..829bbc526758 100644 --- a/mm/migrate_device.c +++ b/mm/migrate_device.c @@ -747,13 +747,25 @@ static void __migrate_device_pages(unsigned long *src_pfns, if (is_device_private_page(newpage) || is_device_coherent_page(newpage)) { - /* - * For now only support anonymous memory migrating to - * device private or coherent memory. - */ + if (mapping) { - src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; - continue; + struct folio *folio; + + folio = page_folio(page); + + /* + * For now only support anonymous memory migrating to + * device private or coherent memory. + * + * Try to get rid of swap cache if possible. + * page is here file or swapcache page, could be shmem also + * folio_test_anon() filters out file and shmem + * + */ + if (!folio_test_anon(folio) || !folio_free_swap(folio)) { + src_pfns[i] &= ~MIGRATE_PFN_MIGRATE; + continue; + } } } else if (is_zone_device_page(newpage)) { /*