Received: by 2002:a05:7412:6592:b0:d7:7d3a:4fe2 with SMTP id m18csp757872rdg; Thu, 10 Aug 2023 20:38:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEEDIlE6APcwACfwh+LzG6Z7vXGQaobx+CM8+YGNrkNBWMYCVKbWiaU+wcmlKLWLetmpZmr X-Received: by 2002:a17:902:e5c3:b0:1bd:a50a:e334 with SMTP id u3-20020a170902e5c300b001bda50ae334mr482238plf.69.1691725085854; Thu, 10 Aug 2023 20:38:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691725085; cv=none; d=google.com; s=arc-20160816; b=kki2d7cYVbhPcuV3y9WrQwMOYrpziZ0Va3LqedX1srClexvA0EX4BjLW0Ya3aQcAqc GcIiX7IgNlpM1LQSEvf1sKGbuSJDE5+DSSkb38cUYY80VPkl/ube9n1jN8MCcPYcdQJw 1qN+QvrTm5MsKBF8yNykAbjwil3TIT+4IVYnPldd2+qkmrKauPv+efSX2gcb93nSh/P3 aeIyXi7BEvlA+w4Q+5XAZmrfC8RozVRkzDlQlNP/9K+iwb1u/LwHmxp3M/70XBc/0aLp xrHiezTUQMyajeY6SPVpLDKiiTlvjJSqE8b4Oa5ocomqrAFipvp/kaKiXE0gYx0oICoE TERA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=T/6IBGxvbs1iGn/MQuI+u3TgZtrfb6xubN9hT9j684k=; fh=Dlhvv22FNegAJ66TUd1aPiTXZ6f+Ak2Xfz487RBtsV0=; b=nRumfqAzOlu0Sitn+UYrvoID3GBMBLVzkhkeAB98fFVoB72znodZMTc9AUbL6ymLz6 DhKfBvY8WlBLrG6eKLWGyKioGG9hIosuv6XfyV4RPGplf87Wq9Ovp5W055L4AqcsVWKI 0xHrOcvXBuWb9j1d7OJK+lL/JjFG2nQXH2eQv2yd114u7ZDE/wZV2X97QMdXZ+eiNAs4 uAKxSs+QJ+y3cdKd0d2dsg7vdH134AraaU8gq0lQpmgwaV5cQ5qaOJe1KC3pmRH0VEm+ PKKzm7+J30zaCTvqjbXeCl+t0m93QRmy8uJun7ZsrBW/mFdvVHk25FKwqVczMmqXNg+I wMSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SJ+CBofT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c2-20020a170902d48200b001bb993ef74bsi2710957plg.540.2023.08.10.20.37.53; Thu, 10 Aug 2023 20:38:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b=SJ+CBofT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231684AbjHKDDf (ORCPT + 99 others); Thu, 10 Aug 2023 23:03:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229468AbjHKDDd (ORCPT ); Thu, 10 Aug 2023 23:03:33 -0400 Received: from mail-qt1-x82b.google.com (mail-qt1-x82b.google.com [IPv6:2607:f8b0:4864:20::82b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA612E76 for ; Thu, 10 Aug 2023 20:03:32 -0700 (PDT) Received: by mail-qt1-x82b.google.com with SMTP id d75a77b69052e-4036bd4fff1so102901cf.0 for ; Thu, 10 Aug 2023 20:03:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1691723012; x=1692327812; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=T/6IBGxvbs1iGn/MQuI+u3TgZtrfb6xubN9hT9j684k=; b=SJ+CBofTKMcexloEe60fwre6ZHLjsGv81s3rnOpM481+csQhSDlbPt6CNivGdvLlgf AIlPdJnCgq2/eO/mhfpysF3UAo8zYOR+STh+ydJa4IlWWnzGpSHlI5f0pVlcpAOWBnCp vIqgfYZ962k02KQHcysjZM8SE3k6nGwHzzhIIY4gdIzzrAfC9X4ZLrYI/7PzVHsQP8PZ eywD78OfWAIbyapwXrMB8CZYH+xoFaDzerJPJD6Tz4o9VzAFGkbpmkCTFYmzfDEPRPvJ 4JtsXYe5MvBSzIYKMefWjEGZRQtDBtm0WA+s1V2nP2ML8zTHQ3u5Hj3OukyufnDo3qFy 8M8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691723012; x=1692327812; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T/6IBGxvbs1iGn/MQuI+u3TgZtrfb6xubN9hT9j684k=; b=MejhxM07i8+owiRjSsAlti/G5kvRsMKJ7tSt5IjDRtkAcWt8E9FfVG/7O4wFbe3a7T ojYTcdKMR0aE7m9BCVgKBdsIE/OECDovxbahxQRDeWBRNcMLhXxHdzCG9MuSC+wrcLCM QrOaJ5t6y3dGQVKBcvmoF5gLswBYSO42Ldfl0sTnmloEc43bglqXu6xYhSVQnTFPDiYz gHhY5dRrvr6JTkAbEAIYK3GzNDdUy7GSKH3YEtJwzunudmqKqjLwEv9ry+9g19ZUUawJ u2+ZtNf5C4wzTpJvdoSsDQ8xqgo1oZQBqkQtm4uK0QIcRCqnP64NjI5reSWs2PG3FEs8 cxYA== X-Gm-Message-State: AOJu0Yz1eqerw0r+BeziNaxYoOk9rJvpJQVstKOJ0V26A37qBLD6puax ty4Q2ZmMdcyjvA2htUAyyVdwIYN2QcctYUd+Ys6d90gDmHd2YawOePP4uRu8 X-Received: by 2002:a05:622a:245:b0:403:b1e5:bcae with SMTP id c5-20020a05622a024500b00403b1e5bcaemr150829qtx.10.1691723011716; Thu, 10 Aug 2023 20:03:31 -0700 (PDT) MIME-Version: 1.0 References: <20230810095652.3905184-1-fengwei.yin@intel.com> <26949c92-95a0-414f-918a-8b8cc11e3e9c@intel.com> <3732dd16-148d-4ac6-8295-86a12f89365b@intel.com> <6cc1654a-460c-474a-864c-04a53ca1ca05@intel.com> In-Reply-To: <6cc1654a-460c-474a-864c-04a53ca1ca05@intel.com> From: Yu Zhao Date: Thu, 10 Aug 2023 21:02:55 -0600 Message-ID: Subject: Re: [PATCH] zswap: don't warn if none swapcache folio is passed to zswap_load To: "Yin, Fengwei" Cc: Yosry Ahmed , linux-kernel@vger.kernel.org, linux-mm@kvack.org, akpm@linux-foundation.org, willy@infradead.org, hannes@cmpxchg.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 10, 2023 at 6:37=E2=80=AFPM Yin, Fengwei wrote: > > > > On 8/11/2023 7:43 AM, Yu Zhao wrote: > > On Thu, Aug 10, 2023 at 5:31=E2=80=AFPM Yin, Fengwei wrote: > >> > >> > >> > >> On 8/11/2023 7:15 AM, Yosry Ahmed wrote: > >>> On Thu, Aug 10, 2023 at 4:09=E2=80=AFPM Yin, Fengwei wrote: > >>>> > >>>> > >>>> > >>>> On 8/11/2023 2:44 AM, Yu Zhao wrote: > >>>>> On Thu, Aug 10, 2023 at 3:58=E2=80=AFAM Yin Fengwei wrote: > >>>>>> > >>>>>> With mm-unstable branch, if trigger swap activity and it's possibl= e > >>>>>> see following warning: > >>>>>> [ 178.093511][ T651] WARNING: CPU: 2 PID: 651 at mm/zswap.c:1387= zswap_load+0x67/0x570 > >>>>>> [ 178.095155][ T651] Modules linked in: > >>>>>> [ 178.096103][ T651] CPU: 2 PID: 651 Comm: gmain Not tainted 6.5= .0-rc4-00492-gad3232df3e41 #148 > >>>>>> [ 178.098372][ T651] Hardware name: QEMU Standard PC (i440FX + P= IIX,1996), BIOS 1.14.0-2 04/01/2014 > >>>>>> [ 178.101114][ T651] RIP: 0010:zswap_load+0x67/0x570 > >>>>>> [ 178.102359][ T651] Code: a0 78 4b 85 e8 ea db ff ff 48 8b 00 a= 8 01 0f 84 84 04 00 00 48 89 df e8 d7 db ff ff 48 8b 00 a9 00 00 08 00 0f 8= 5 c4 > >>>>>> [ 178.106376][ T651] RSP: 0018:ffffc900011b3760 EFLAGS: 00010246 > >>>>>> [ 178.107675][ T651] RAX: 0017ffffc0080001 RBX: ffffea0004a991c0= RCX:ffffc900011b37dc > >>>>>> [ 178.109242][ T651] RDX: 0000000000000000 RSI: 0000000000000001= RDI:ffffea0004a991c0 > >>>>>> [ 178.110916][ T651] RBP: ffffea0004a991c0 R08: 0000000000000243= R09:00000000c9a1aafc > >>>>>> [ 178.112377][ T651] R10: 00000000c9657db3 R11: 000000003c9657db= R12:0000000000014b9c > >>>>>> [ 178.113698][ T651] R13: ffff88813501e710 R14: ffff88810d591000= R15:0000000000000000 > >>>>>> [ 178.115008][ T651] FS: 00007fb21a9ff700(0000) GS:ffff88813bc8= 0000(0000) knlGS:0000000000000000 > >>>>>> [ 178.116423][ T651] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080= 050033 > >>>>>> [ 178.117421][ T651] CR2: 00005632cbfc81f6 CR3: 0000000131450002= CR4:0000000000370ee0 > >>>>>> [ 178.118683][ T651] DR0: 0000000000000000 DR1: 0000000000000000= DR2:0000000000000000 > >>>>>> [ 178.119894][ T651] DR3: 0000000000000000 DR6: 00000000fffe0ff0= DR7:0000000000000400 > >>>>>> [ 178.121087][ T651] Call Trace: > >>>>>> [ 178.121654][ T651] > >>>>>> [ 178.122109][ T651] ? zswap_load+0x67/0x570 > >>>>>> [ 178.122658][ T651] ? __warn+0x81/0x170 > >>>>>> [ 178.123119][ T651] ? zswap_load+0x67/0x570 > >>>>>> [ 178.123608][ T651] ? report_bug+0x167/0x190 > >>>>>> [ 178.124150][ T651] ? handle_bug+0x3c/0x70 > >>>>>> [ 178.124615][ T651] ? exc_invalid_op+0x13/0x60 > >>>>>> [ 178.125192][ T651] ? asm_exc_invalid_op+0x16/0x20 > >>>>>> [ 178.125753][ T651] ? zswap_load+0x67/0x570 > >>>>>> [ 178.126231][ T651] ? lock_acquire+0xbb/0x290 > >>>>>> [ 178.126745][ T651] ? folio_add_lru+0x40/0x1c0 > >>>>>> [ 178.127261][ T651] ? find_held_lock+0x2b/0x80 > >>>>>> [ 178.127776][ T651] swap_readpage+0xc7/0x5c0 > >>>>>> [ 178.128273][ T651] do_swap_page+0x86d/0xf50 > >>>>>> [ 178.128770][ T651] ? __pte_offset_map+0x3e/0x290 > >>>>>> [ 178.129321][ T651] ? __pte_offset_map+0x1c4/0x290 > >>>>>> [ 178.129883][ T651] __handle_mm_fault+0x6ad/0xca0 > >>>>>> [ 178.130419][ T651] handle_mm_fault+0x18b/0x410 > >>>>>> [ 178.130992][ T651] do_user_addr_fault+0x1f1/0x820 > >>>>>> [ 178.132076][ T651] exc_page_fault+0x63/0x1a0 > >>>>>> [ 178.132599][ T651] asm_exc_page_fault+0x22/0x30 > >>>>>> > >>>>>> It's possible that swap_readpage() is called with none swapcache f= olio > >>>>>> in do_swap_page() and trigger this warning. So we shouldn't assume > >>>>>> zswap_load() always takes swapcache folio. > >>>>> > >>>>> Did you use a bdev with QUEUE_FLAG_SYNCHRONOUS? Otherwise it sounds > >>>>> like a bug to me. > >>>> I hit this warning with zram which has QUEUE_FLAG_SYNCHRONOUS set. T= hanks. > >>> > >>> Does it make sense to keep the warning and instead change it to check > >>> SWP_SYNCHRONOUS_IO as well? Something like: > >>> > >>> VM_WARN_ON_ONCE(!folio_test_swapcache(folio) && > >>> !swap_type_to_swap_info(type)->flags && SWP_SYNCHRONOUS_IO); > >>> > >>> Of course this is too ugly, so perhaps we want a helper to check if a > >>> swapfile is synchronous. > >> My understanding was that the WARN here is zswap_load() doesn't expect > >> a folio not in swapcache. With zram, swap_readpage() must accept the > >> folio not in swapcache. So this warn should not be there. > >> > >> But your comment make more sense to me. I will update the patch not > >> to remove this WARN. Thanks. > > > > That can cause another warning. > My understanding is that WARN may be wanted by zswap code. > > > > > Please don't overegineer. The original patch looks good to me. What Yosry suggested seems not only overengineered but also can cause a new KCSAN warning.