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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 90575C25B76 for ; Tue, 11 Jun 2024 04:14:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 971986B0089; Tue, 11 Jun 2024 00:14:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8F99B6B008C; Tue, 11 Jun 2024 00:14:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 74B7E6B0093; Tue, 11 Jun 2024 00:14:28 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 538D56B0089 for ; Tue, 11 Jun 2024 00:14:28 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id B9FCE160A0B for ; Tue, 11 Jun 2024 04:14:27 +0000 (UTC) X-FDA: 82217290974.21.2F85D98 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id A7BA01C001E for ; Tue, 11 Jun 2024 04:14:25 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zj9qrqwZ; spf=pass (imf18.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=1718079265; a=rsa-sha256; cv=none; b=y1/M01QZSdwpZbE4FqXg8uiVQqnHv8rLBorUltKrhwyebaeTeTiHPr6ISKNXya/a3dcaph YY0+vw2e755eqxSh6lyQVUgsYKUgL9jiwcU4W0hPUOIW6VwasKCqJaUXeggYRm6UWMD0HN fSG/i9/Ruvqk2cEQVHT4ZCTkr5KmKwY= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Zj9qrqwZ; spf=pass (imf18.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=1718079265; 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:in-reply-to:references:references:dkim-signature; bh=v1a8FseTl06wVgP6A7MAh41W7oTDkozR9kmXYeqUqGQ=; b=pY9UwhqoJXSpScN2j6voxlk1XbzFYNizbIP/x/7s/xYZ6s7+btvSP/DT8kpRfSLSyvs0ig t/xTlplGpZH6hluHkJYRVZejKNiq3E+POFUryw1eLjmtQIKY2Kf4edQ5lPkmwOO3eLEPN/ RuhHD7lLUZxXngUbX2bvkXxPTo/b27M= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1718079265; 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=v1a8FseTl06wVgP6A7MAh41W7oTDkozR9kmXYeqUqGQ=; b=Zj9qrqwZSN8UrMBOfm5kZEkF0JG6xw6WFzIUtiKI2/r8QKb7uEHfbqGAR/XBPLsdf1U1VI 8FhJhViAqzKcVXSafq7LYk8tPrlRyGp/Zc8ESXo9KxvEUyzREcPAPZH34nuxJIkI2cu3KZ ut4AO9kxCol1Z16gKsTH3Kb34nhxYKs= 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-384-VWm2joglPjiO6TFoke0jiA-1; Tue, 11 Jun 2024 00:14:22 -0400 X-MC-Unique: VWm2joglPjiO6TFoke0jiA-1 Received: by mail-lj1-f198.google.com with SMTP id 38308e7fff4ca-2ebd982d244so20238501fa.3 for ; Mon, 10 Jun 2024 21:14:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718079261; x=1718684061; 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=v1a8FseTl06wVgP6A7MAh41W7oTDkozR9kmXYeqUqGQ=; b=VgPVS/WDAHWZjiqA2Z4j3LtVkws+G/lPByxXMV7/4fNh3ktWVOm4L5myc4YKcjD7BY IgM2bhBIt0/ArkHQjx7N068YYMMRl8L8G9OvybLXCD1Ua4cupLpoZNIh/0aUi/qM0pAX KgoOzFQAirlf/cU9Z/ZUfRbEFaExrr1oZrC/OJ9UZ5ZTjxz26GrUI3iMA0hOr3CPxPf8 OFHvKF2sBEGtf019z7uAEq+/CEsz+TSY150jhj6dkAwJUJ3PNAKGbZe1hEvIVCLIma7X HuBZGz7er354X1BiVdHhYf3heiLsr3x6ZBT6A7X3CIVkWrR9Yo94f8GCFCSKdmFO0nbC S7QA== X-Forwarded-Encrypted: i=1; AJvYcCXinQB1ofJGBkRJmzUaIuEwNCGBT6vw/QIVxrd4Meu2LkqETZJVwGV3OQAuoWkMaErie2e2U4KiIQHIUFyUWaefDwo= X-Gm-Message-State: AOJu0YzEI/GlLxyN4SuthjytLxGqC8b2oO1/FUkgMBLF4NYLstXMGCyT Pc5qCq6+weEm3AtntjcF6AHRBSwa3S/snuTj8LWqtDo684Da/kEDwIRAqfUr+vFcP2IAYbyE159 xwYs8cqdyAIMWs+enTrMDXyN0+ckMtOrfFnZE4r1r4sc0GL0= X-Received: by 2002:a2e:984c:0:b0:2eb:dec1:6276 with SMTP id 38308e7fff4ca-2ebdec164f1mr36099321fa.0.1718079260778; Mon, 10 Jun 2024 21:14:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IF18U05dfo0rZSYfNFu7sSh3sPoBIH4illqphSfrkMLiBcV/ScEVjN611SrAd51tjNmzYwCRA== X-Received: by 2002:a2e:984c:0:b0:2eb:dec1:6276 with SMTP id 38308e7fff4ca-2ebdec164f1mr36099151fa.0.1718079260393; Mon, 10 Jun 2024 21:14:20 -0700 (PDT) Received: from [192.168.1.86] (85-23-17-83.bb.dnainternet.fi. [85.23.17.83]) by smtp.gmail.com with ESMTPSA id 38308e7fff4ca-2eaeaff2a05sm15898821fa.45.2024.06.10.21.14.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 10 Jun 2024 21:14:19 -0700 (PDT) Message-ID: <811778e4-6af4-563a-757e-83fec207e79f@redhat.com> Date: Tue, 11 Jun 2024 07:14:19 +0300 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 Subject: Re: [PATCH v2] mm: zswap: handle incorrect attempts to load of large folios To: Yosry Ahmed Cc: Andrew Morton , Johannes Weiner , Nhat Pham , Chengming Zhou , Baolin Wang , Barry Song <21cnbao@gmail.com>, Chris Li , Ryan Roberts , David Hildenbrand , Matthew Wilcox , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20240608023654.3513385-1-yosryahmed@google.com> <2821278f-bc94-c147-d0fe-8cc52dbdccb1@redhat.com> From: =?UTF-8?Q?Mika_Penttil=c3=a4?= In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-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ipBthjK4LzTX7daD+ Bva2OU1t GmZBOsFdfZGXGZzfP/zX8EzH0jRgRMVgPzEXefIplRZRzf0ALkRftsqLtp10kOrYzDIrTD2XQIMu81wzzTP5u1tuh17zv8Fe+2Mpx76D3wNiK1Vxs0h0IS1x3ucnX0G99x60FgmsBCZqqvHcBx/o2NcddG0IKJ9xf8TU31UG2zwYAOEXuwX+jjedtB0JpY2qnv+kRMRCHG07gnv0bobCsX4uuM70MWGOWm8VUUPRFygTVP31E085RK8iqOsV834KdGX6N+9m5N/8bzyKGALTDvFMEzSOc0cZ7LToObSaXGpMK+/mzpPqnOFcaFv/PcUPcZv1TlLqS38r+PbaFjPEkMFyLwXQf5Lqj7zcaiSJ2nr9MeXixn5pF4anl7JBZex0HZ4cchJ2FX/1BWcA= 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: List-Subscribe: List-Unsubscribe: On 6/10/24 20:35, Yosry Ahmed wrote: > On Fri, Jun 7, 2024 at 9:08 PM Mika Penttilä wrote: >> On 6/8/24 05:36, Yosry Ahmed wrote: >>> diff --git a/mm/zswap.c b/mm/zswap.c >>> index b9b35ef86d9be..ebb878d3e7865 100644 >>> --- a/mm/zswap.c >>> +++ b/mm/zswap.c >>> @@ -1557,6 +1557,26 @@ bool zswap_load(struct folio *folio) >>> >>> VM_WARN_ON_ONCE(!folio_test_locked(folio)); >>> >>> + /* >>> + * Large folios should not be swapped in while zswap is being used, as >>> + * they are not properly handled. Zswap does not properly load large >>> + * folios, and a large folio may only be partially in zswap. >>> + * >>> + * If any of the subpages are in zswap, reading from disk would result >>> + * in data corruption, so return true without marking the folio uptodate >>> + * so that an IO error is emitted (e.g. do_swap_page() will sigfault). >>> + * >>> + * Otherwise, return false and read the folio from disk. >>> + */ >>> + if (folio_test_large(folio)) { >>> + if (xa_find(tree, &offset, >>> + offset + folio_nr_pages(folio) - 1, XA_PRESENT)) { >>> + WARN_ON_ONCE(1); >>> + return true; >>> + } >> How does that work? Should it be xa_find_after() to not always find >> current entry? > By "current entry" I believe you mean the entry corresponding to > "offset" (i.e. the first subpage of the folio). At this point, we > haven't checked if that offset has a corresponding entry in zswap or > not. It may be on disk, or zwap may be disabled. Okay you test if there's any matching offset in zswap for the folio. >> And does it still mean those subsequent entries map to same folio? > If I understand correctly, a folio in the swapcache has contiguous > swap offsets for its subpages. So I am assuming that the large folio > swapin case will adhere to that (i.e. we only swapin a large folio if > the swap offsets are contiguous). Did I misunderstand something here? Yes I think that is fair assumption for now. But also saw your v3 which doesn't depend on this. > >> >> --Mika >> >>