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 66234C54E58 for ; Fri, 22 Mar 2024 03:04:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D856A6B0087; Thu, 21 Mar 2024 23:04:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D35A86B0089; Thu, 21 Mar 2024 23:04:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C4ADD6B008A; Thu, 21 Mar 2024 23:04:35 -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 B5F776B0087 for ; Thu, 21 Mar 2024 23:04:35 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 76EDFC0289 for ; Fri, 22 Mar 2024 03:04:35 +0000 (UTC) X-FDA: 81923182110.07.2B6BC09 Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com [209.85.208.173]) by imf24.hostedemail.com (Postfix) with ESMTP id B965A180006 for ; Fri, 22 Mar 2024 03:04:32 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=CGARtHti; spf=pass (imf24.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711076673; a=rsa-sha256; cv=none; b=oGhHemRQAV9yYzSnTGeAoqVx1zmHaRvdHRcNCVb5KGooUtNkfs82LLmimixrD2yq0SlMIT pKmzNrLjyiOh8ZZ390Z3QQyDQ9Le9uZixptImKv+fx9RcybfWX79yUbNQyKvV9WcaNJ8lM BnanzHIuxhexV2ntx5GLmAxlgPUVWys= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=bytedance.com header.s=google header.b=CGARtHti; spf=pass (imf24.hostedemail.com: domain of hezhongkun.hzk@bytedance.com designates 209.85.208.173 as permitted sender) smtp.mailfrom=hezhongkun.hzk@bytedance.com; dmarc=pass (policy=quarantine) header.from=bytedance.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711076673; 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=NMGsT6oCxRJ06Rd8AkivPy2YicRTyEx8JxjQfNH557A=; b=bSjgMzZHaYJhkQRcPokzWXYEM/xD/NQJAqEVWWd4ZGdLrFXG/dmMISlp75YyvdyPy3IUdX yzFCQZK1aXNM6ig04y2iarvOYd31eELcIhlImAu2Nk5rL6w7Z+WxJ4TbeDjsGvMXlQ41zh 2f3PcitlsqjgoinYtvk2uTdfMSSCLqM= Received: by mail-lj1-f173.google.com with SMTP id 38308e7fff4ca-2d4515ec3aaso13978431fa.1 for ; Thu, 21 Mar 2024 20:04:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bytedance.com; s=google; t=1711076671; x=1711681471; darn=kvack.org; 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=NMGsT6oCxRJ06Rd8AkivPy2YicRTyEx8JxjQfNH557A=; b=CGARtHtim8g+qevo5avhAvnVaaLrWjTnlsGfczXHDxsTCE55qZNMopz97AS2mcBolA 3qwyp53lZ2E3DisWM+22Z/qn5HrC01bEkOIjHiDBnmtyIyUC57O7ad3ZHDpXNli6R+kz b+lL+nPTvNRUKJ4qzjXNZ/FEVcL1yBlqjYE8hDDBRuOwM7niCT9BMphaz0o9sz0CDXvb bmv9T3tcqmI2f5IlMVaQ2ZzPfDHHQ5O4AF4MoEQGYTrek17W1gt8VWCEHV74Jjw59Vgg v80237TNdvVO3axvMA0kPFexFX8JyehXXQv2hXnLEqWGDmxdSXTyqhZcLaZAhKkCTcBC JKIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711076671; x=1711681471; 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=NMGsT6oCxRJ06Rd8AkivPy2YicRTyEx8JxjQfNH557A=; b=SiLvpJ2Jxp4MnKvzHEG0GzWoF/yOinOK55isWORI3+8xIVPsvEJTZc/whmdn2Qxp0O c+oNdlw6c2kZOAmL6itLbTDjq9RkyspYijybRh1h6y2ur64IHsjKAUf1dd8SasT5Eizl Ui/LVfpURZmZ5iA69zBYfcZMRy2mAgy//wXSe50C+1j3MtXmEuiK0KN4C52U51Jr2NXG TktVOjjzMh70HqvRNoTM7bCKH1pMn6EI7QsH/goATH0H3UYenmTPfdbsen72kHIvw4Vu kDKXQDnyson2BhWnaBXd1V4cJhkx7HIOd8dZtbtFcLOcoRpBi6Mf5Yxz50rPW3Kjc98D pdjg== X-Forwarded-Encrypted: i=1; AJvYcCUHXa8855F9duAUptKHCyD5+uIYhWbMjiAJ2pAEWcxgnhJDS0EoPMjz/MEVpW9cdb9AKRZ/0a/lIa3yjXkzhuePYOg= X-Gm-Message-State: AOJu0YyISjaBsFyUF/iIvQl7x0lCZZFcNNc263RsD6AF8+ZBlPgVYv8M ROMCn/SMQlJibwyjrUFL3cIObddpamCnA0Ezkt2XKwIRu/hzc8MfnT5E84X7T7sSBxyMmUZaL58 ynExGrjGjanuVsdAo6+pgrV3akQXAMPNYLWAZsg== X-Google-Smtp-Source: AGHT+IHXvbZJEYpIE/5H4INeYV0Bm7qtk5EyMgp8JqX3QEt9GpQmKxUeFSrfqjynO2bzMhtvQwCmlfrKRhlKJYu38dY= X-Received: by 2002:a2e:918c:0:b0:2d4:e6d:ab5b with SMTP id f12-20020a2e918c000000b002d40e6dab5bmr229813ljg.22.1711076670721; Thu, 21 Mar 2024 20:04:30 -0700 (PDT) MIME-Version: 1.0 References: <01b0b8e8-af1d-4fbe-951e-278e882283fd@linux.dev> In-Reply-To: From: Zhongkun He Date: Fri, 22 Mar 2024 11:04:18 +0800 Message-ID: Subject: Re: [External] Re: [bug report] mm/zswap :memory corruption after zswap_load(). To: Chengming Zhou Cc: Johannes Weiner , Yosry Ahmed , Andrew Morton , linux-mm , wuyun.abel@bytedance.com, zhouchengming@bytedance.com, Nhat Pham Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: B965A180006 X-Stat-Signature: d8kd1rrnnpfitc3ez57fn831wbtb65hw X-Rspam-User: X-HE-Tag: 1711076672-671004 X-HE-Meta: U2FsdGVkX18Yn86Rv05nVkioVvHMvWgCXwYM99dRqL+I82XzCP4mrDojiNGCQ2rDPgge0psNsRAG4jSvJXNcTHxAI8QZVLbs+f44ZLjgh/kz7PZ/YIqoiSHSD6a+BJKf16TSK5kvmWLo0oO3v1hcqz5/Cvs8cK1vwyUwVg+mKJxTJhBp5qwL1FzaHN7sBMkrrkWjT3R9Fgz6qmGRzrhsxd4AoJMT43Pih1GrwGzgYN1TXGrXHKATae8XsQriruUnfkN8szuqhr6TsVR6ZrtapvTc+6lVufsG2JILJAAO57MsjECe6YQSduVYQmE/ajjQipPMIVrAs8x0PEclHoi3KD5Pu7uc+IDJmUPD51rGfpyMO0+j69kXNGNjiUIoPpTTMIA69ENRUyrTq1i/bickuewQeLAhgM/qZ5woU0ekX3y5O6PqFD5nQL1tCoeILHPrwtTA9SzTREISTtu6hLezMtZ0Vza6RlZjqJV1KRKC5kgTtleavV2011NxBKtvlve/t6vSrWaoQD7uI23BQdNmBIWXEEDBguhW2cHlPrWRYYFUDCxD/M96/c/S7wfYtEUmaAJwuPVw0YYyDtGl9IerTWrOpeRIzhF0KrTo6hDo0JNONQpcNyLbx/OolOrA7lLo2dbtTQzbx+2TcBLLS6eWiKWvsQ2S1Bdf6IFP12U8aNOniQZmk9qciC/VsExBpwwy9+Au1YvoTanGtuSufuaR5yBWv9RzKUnefJuzYm4/V19Fgml7n6iUeV7XDC8ajIvFc4wz5pcz6LDxzyUe3L4o8e0yYHITuyxqQhn2p5BmhlKbXPGpP8r+JraqomxST+3MHe7OZid4fs0TcpNJYESAazdEoI2IGGxGUgheffPVGApW4Fk7r+m+Kq6P+CczqqqaM+7bmKPLrgyyph5U6dIeN2wyzcTuu32vo8sAACNkxFmepXL/JWhtaiOyxUM6NwtUmwpM4+0ufK9vcneGORq BDTiX3Jr TjEjGciIIpVDJAedtESCCWhXC/0EFMCaFQx7/3Cq5cJWPCs/3aiZQVbydPNbf0dv/0dLEsYsXDLIdMXaqY0ZXCGY19AqTvR/Wo7fClrvXviKWZPqv0nefsLBCAo/WAXGEZTp7DVOgfe08yssj9fQiqbpwScP5i9Fzxu9c70WnkI2IC6cIq9Fv+wEee1KtCz+aVQmorDkRdJqBcdXoiIJdKH+1VRZz0JpGrUTxv3OOS4yhK9Ca2emKyD9RV1aBgP4ACz3jyZoL7bAuCKtQV5hIuTyhIs6bRiK+hFkK 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 Thu, Mar 21, 2024 at 5:29=E2=80=AFPM Chengming Zhou wrote: > > On 2024/3/21 14:36, Zhongkun He wrote: > > On Thu, Mar 21, 2024 at 1:24=E2=80=AFPM Chengming Zhou wrote: > >> > >> On 2024/3/21 13:09, Zhongkun He wrote: > >>> On Thu, Mar 21, 2024 at 12:42=E2=80=AFPM Chengming Zhou > >>> wrote: > >>>> > >>>> On 2024/3/21 12:34, Zhongkun He wrote: > >>>>> Hey folks, > >>>>> > >>>>> Recently, I tested the zswap with memory reclaiming in the mainline > >>>>> (6.8) and found a memory corruption issue related to exclusive load= s. > >>>> > >>>> Is this fix included? 13ddaf26be32 ("mm/swap: fix race when skipping= swapcache") > >>>> This fix avoids concurrent swapin using the same swap entry. > >>>> > >>> > >>> Yes, This fix avoids concurrent swapin from different cpu, but the > >>> reported issue occurs > >>> on the same cpu. > >> > >> I think you may misunderstand the race description in this fix changel= og, > >> the CPU0 and CPU1 just mean two concurrent threads, not real two CPUs. > >> > >> Could you verify if the problem still exists with this fix? > > > > Yes=EF=BC=8CI'm sure the problem still exists with this patch. > > There is some debug info, not mainline. > > > > bpftrace -e'k:swap_readpage {printf("%lld, %lld,%ld,%ld,%ld\n%s", > > ((struct page *)arg0)->private,nsecs,tid,pid,cpu,kstack)}' --include > > linux/mm_types.h > > Ok, this problem seems only happen on SWP_SYNCHRONOUS_IO swap backends, > which now include zram, ramdisk, pmem, nvdimm. Yes. > > It maybe not good to use zswap on these swap backends? > > The problem here is the page fault handler tries to skip swapcache to > swapin the folio (swap entry count =3D=3D 1), but then it can't install f= olio > to pte entry since some changes happened such as concurrent fork of entry= . > The first page fault returned VM_FAULT_RETRY because folio_lock_or_retry() failed. > Maybe we should writeback that folio in this special case. >