Received: by 2002:a05:6500:1b45:b0:1f5:f2ab:c469 with SMTP id cz5csp291389lqb; Tue, 16 Apr 2024 16:30:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWpbZOGGAsHVwBYv7gVfqBVf6QfKPjQpcUvZxKeFR4vSI3ynFp/y+fkcZihP16Fs5ZratLilnC9XQbtPqbpcxyNOGoRZg8s/Zbo+Uti9w== X-Google-Smtp-Source: AGHT+IH+SeVEix2HUGKmIDsrPso5k9hl7WvcXe1kSi4cp2Q1Rxta3TFmHZN4gY3Zw/LGVMMK2d1c X-Received: by 2002:a05:620a:a19:b0:78e:f6de:b91d with SMTP id i25-20020a05620a0a1900b0078ef6deb91dmr3460243qka.36.1713310199916; Tue, 16 Apr 2024 16:29:59 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713310199; cv=pass; d=google.com; s=arc-20160816; b=MbHtfqvQxTAYMnXwFKl6VGmaKTmKmjlwZL0SRfEmwf3X7RjGTPEkoEx/cgYA4a3O5e LSrqJcuMiHb7y9s/VqPnjMS/Mb0dZgEjX4vACHJlyxH/z6EplKHTL1E6KiHhsElA4uqn O60bLZc/exa59OlYDNXOjCcOVg7HuPBz0UvQZsIK2+vtCpY/Es0Z5jRuR3V+z4ZNPgSq 3LudHcWR7K0oVAlAbBHpeRTFHKPdza8n16FSIDmsgXx0o1eO1bCkvj9gb73Qx69jqSE8 6+X0OpZa0ORdLPrgE2OUQosObU3gKMtHnV1g0HgLQwnOpD0uIbMl15baeq6HPVQrE8cP yUXw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=XLy1Ua1b77r4qsxuukriMKLfQ+NQtqpcoJqaT5UdrRA=; fh=tJu3j8ClfN3wNbdGRAmBHW4/usnKQXJ03ljM2dpXHj8=; b=KL6Pyhrc+/qq1uTddeP1FmRVz1ruF9qhr8qN8zgQxHZNpiOc1NYLtEqEhnvFE8w66A /SP0LPzDPv4rI9e8cT9V339WQOD291BSBpcmtq+X5bTiIFKCCQ8y97Myi/19DfTjG3dS Y8DDew09LcIopP9QMveBhXhMko58SdPQ5EYGQCwS928+0viNEXEzIM2BXca3+i2kSQfh Pz/4wBGC/F1/ah/6XcnGzvh6b45XPeBMUEuVf5wBk2tucVpxSmRoKgG6W2s2jGUlcjh0 B+5Q3z+0XiZFfxxhPwThPGk5Wh22iEQ9JBNmNnGgG/YBZCYL/iXS/YxHYwfN3RFGgWx4 x5VQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ma53oj7G; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-147751-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d12-20020a05620a204c00b0078ecd1445e3si10749514qka.703.2024.04.16.16.29.59 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 16:29:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-147751-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ma53oj7G; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-147751-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-147751-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 964AE1C21081 for ; Tue, 16 Apr 2024 23:29:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C27E913A88A; Tue, 16 Apr 2024 23:29:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ma53oj7G" Received: from mail-qv1-f53.google.com (mail-qv1-f53.google.com [209.85.219.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 70B5F6EB44 for ; Tue, 16 Apr 2024 23:29:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713310193; cv=none; b=iOr6JTF2GKgIG3OlTEvB3vEOsStBbY+V0+1EfBLQSYDxt/KgKKieUIjp6lHfOXWdnpfZtUx+5UYxzC0zz9d9quJk7OSWPmEsPLFGnAgmmNHO37HKnnWy9guYK4065nlQFV5MNw28WsskY5zhctyWuYmRzkUSAqheTj3R67y1FVw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713310193; c=relaxed/simple; bh=y15kkh/UzNlt8PyzGY6czdnu89oxFroFanLzwhfD0N8=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=YHh4DEXpn5VujyecKxbNH7ZQT/+NkscXCCvXQGczllOt8LK5vQNE589vvupjt6kNu4Bzd2nd5ubu339xngy872NkQJY3fZaEmFvMFexNLBou93zgR10dwVENtlkL/rgha/LXlaICkazuG1m/g0WzaMgmlc4Nl+6y/2EcXDRO8rk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ma53oj7G; arc=none smtp.client-ip=209.85.219.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-qv1-f53.google.com with SMTP id 6a1803df08f44-6969388c36fso22917606d6.1 for ; Tue, 16 Apr 2024 16:29:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1713310191; x=1713914991; darn=vger.kernel.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=XLy1Ua1b77r4qsxuukriMKLfQ+NQtqpcoJqaT5UdrRA=; b=ma53oj7GQt0ugRc59D4dVHzcSavxwmJ5qa2S+hmTqwJ4YJ5b62kGz5Moxe2uckKcr+ Zf5JL4IjTyuNVTF3rAQ+wOtAaJQJUIn6mQUXksv1f05fyjNFQ6OB+cyE+ffQwE+TtYmn zQJe3lzjjDyF2pHmLYiNBIcOUDJjEDDUgLfu0zwmqEFfhbzOLVQMioBlmXOtsyia2Iou 9BHaOEfioH7LEv+bYTb1riz5L3q53rTrf7t9Dfu6VXYCdFrIO2kxAxtGqnBPbHz2BajT oHXPE3EcWRaELRvcq+o2yHof5O9L5XbaO/zNE46TP/eInochbcqsmyD3PgkyUbf1ppS+ l0ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713310191; x=1713914991; 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=XLy1Ua1b77r4qsxuukriMKLfQ+NQtqpcoJqaT5UdrRA=; b=ShJ8+AamT8fO1MABma/yGQLEBZg/xwsPx2EP0XBWJOGJB81dE1PcNEyiFsHooIGnd2 icSolhw2wZSnyAHDQHW8e0yIKo85UWXyCf0CAGNi8T7iYqYUqHH1/cRdZLnW7ia/4l8G 0QPVMK6SWGyaKS0RkyKuqIagNv3tNYmQV2hecQ+s2YBls4eYTXnUTIOTogzR06Le1MvN Qh98/8cr7Gp70aYu09RL6fk4e6WEwAzwZpXfzJjwQ/Aj/qX1FO0DmLX8wI/pcx2bweSH 6VitwAYdD6DswUyMsq7hxgHAgMIPsy6mA9XCapFfBYjCS+m/QdSZF0QH48/Je0bZE1uE Uxhg== X-Forwarded-Encrypted: i=1; AJvYcCWLXZXDnYBZIp17iE4S1sLwmvnI7dSGZJvKOFZdRdytyWXXB2nTmeRgSI+ndDDgHgthVRYzXSP1FVaPagE0Byf8DYFlyLXP6CKs1pgq X-Gm-Message-State: AOJu0Ywg08c7+NDqBC4aRKuywEUIdnJySQ7G9gMQbv7fHWejGuu2JwTR LJdmfDzqqq1b5d1xNwywuvh/uh2od2UPxndUjVIlkRy21mecOe2T0yBAAW6v8dkMqKi3shs8fGq Fb7J1W6liegfetrkIA2FAWGfFqDg= X-Received: by 2002:a0c:ea33:0:b0:69b:7c1e:ac02 with SMTP id t19-20020a0cea33000000b0069b7c1eac02mr6282293qvp.18.1713310191203; Tue, 16 Apr 2024 16:29:51 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <3iccc6vjl5gminut3lvpl4va2lbnsgku5ei2d7ylftoofy3n2v@gcfdvtsq6dx2> In-Reply-To: From: Nhat Pham Date: Tue, 16 Apr 2024 16:29:39 -0700 Message-ID: Subject: Re: [REGRESSION] Null pointer dereference while shrinking zswap To: Christian Heusel Cc: Seth Jennings , Dan Streetman , Vitaly Wool , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, David Runge , "Richard W.M. Jones" , Mark W , regressions@lists.linux.dev, Johannes Weiner , Yosry Ahmed , Chengming Zhou Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Apr 16, 2024 at 3:14=E2=80=AFPM Nhat Pham wrote= : > > On Tue, Apr 16, 2024 at 5:19=E2=80=AFAM Christian Heusel wrote: > > > > Hello everyone, > > Thanks for the report, Christian! Looking at it now. > > > > > while rebuilding a few packages in Arch Linux we have recently come > > across a regression in the linux kernel which was made visible by a tes= t > > failure in libguestfs[0], where the booted kernel showed a Call Trace > > like the following one: > > > > [ 218.738568] CPU: 0 PID: 167 Comm: guestfsd Not tainted 6.7.0-rc4-1-m= ainline-00158-gb5ba474f3f51 #1 bf39861cf50acae7a79c534e25532f28afe4e593^M > > Is this one of the kernel versions that was broken? That looks a bit > odd, as zswap shrinker landed on 6.8... Ah ignore this - I understand the versioning now... > > > [ 218.739007] Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS= Arch Linux 1.16.3-1-1 04/01/2014^M > > [ 218.739787] RIP: 0010:memcg_page_state+0x9/0x30^M > > [ 218.740299] Code: 0d b8 ff ff 66 66 2e 0f 1f 84 00 00 00 00 00 66 90= 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 66 0f 1f 00 0f 1f 44 00 00= <48> 8b 87 00 06 00 00 48 63 f6 31 d2 48 8b 04 f0 48 85 c0 48 0f 48^M > > [ 218.740727] RSP: 0018:ffffb5fa808dfc10 EFLAGS: 00000202^M > > [ 218.740862] RAX: 0000000000000000 RBX: ffffb5fa808dfce0 RCX: 0000000= 000000002^M > > [ 218.741016] RDX: 0000000000000001 RSI: 0000000000000033 RDI: 0000000= 000000000^M > > [ 218.741168] RBP: 0000000000000000 R08: ffff976681ff8000 R09: 0000000= 000000000^M > > [ 218.741322] R10: 0000000000000001 R11: ffff9766833f9d00 R12: ffff976= 6ffffe780^M > > [ 218.742167] R13: 0000000000000000 R14: ffff976680cc1800 R15: ffff976= 682204d80^M > > [ 218.742376] FS: 00007f1479d9f540(0000) GS:ffff9766fbc00000(0000) kn= lGS:0000000000000000^M > > [ 218.742569] CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033^M > > [ 218.743256] CR2: 0000000000000600 CR3: 0000000103606000 CR4: 0000000= 000750ef0^M > > [ 218.743494] PKRU: 55555554^M > > [ 218.743593] Call Trace:^M > > [ 218.743733] ^M > > [ 218.743847] ? __die+0x23/0x70^M > > [ 218.743957] ? page_fault_oops+0x171/0x4e0^M > > [ 218.744056] ? free_unref_page+0xf6/0x180^M > > [ 218.744458] ? exc_page_fault+0x7f/0x180^M > > [ 218.744551] ? asm_exc_page_fault+0x26/0x30^M > > [ 218.744684] ? memcg_page_state+0x9/0x30^M > > [ 218.744779] zswap_shrinker_count+0x9d/0x110^M > > [ 218.744896] do_shrink_slab+0x3a/0x360^M > > [ 218.744990] shrink_slab+0xc7/0x3c0^M > > [ 218.745609] drop_slab+0x85/0x140^M > > [ 218.745691] drop_caches_sysctl_handler+0x7e/0xd0^M > > [ 218.745799] proc_sys_call_handler+0x1c0/0x2e0^M > > [ 218.745912] vfs_write+0x23d/0x400^M > > [ 218.745998] ksys_write+0x6f/0xf0^M > > [ 218.746080] do_syscall_64+0x64/0xe0^M > > [ 218.746169] ? exit_to_user_mode_prepare+0x132/0x1f0^M > > [ 218.746873] entry_SYSCALL_64_after_hwframe+0x6e/0x76^M > > > > The regression is present in the mainline kernel and also was > > independently reported to the redhat bugtracker[1]. > > > > I have bisected (see log[2]) the regression between v6.9-rc4 and v6.6 > > and have landed on the following results (removed unrelated test commit= ) > > as remainders since some of the commits were not buildable for me: > > - 7108cc3f765c ("mm: memcg: add per-memcg zswap writeback stat") > > - a65b0e7607cc ("zswap: make shrinking memcg-aware") > > - b5ba474f3f51 ("zswap: shrink zswap pool based on memory pressure") Hmmm, this smells like a memcg reference counting bug to me. The memcg was successfully accessed just a couple of LoCs above, but failed after the stats flushing. My suspicion right now is the new memcg refcnt dance to select an memcg for the global, capacity-based, shrinker, introduced in this patch series. That dance looks solid to me tho - not sure where it goes wrong. And, if it's a reference counting issue, that should pop up in different places (i.e other mysterious memcg traces)...