From patchwork Sun Jan 16 07:02:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Changbin Du X-Patchwork-Id: 12714473 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 593E5C433EF for ; Sun, 16 Jan 2022 07:03:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E5F796B0071; Sun, 16 Jan 2022 02:03:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E0EEA6B0073; Sun, 16 Jan 2022 02:03:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CFD796B0074; Sun, 16 Jan 2022 02:03:03 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0222.hostedemail.com [216.40.44.222]) by kanga.kvack.org (Postfix) with ESMTP id C09A96B0071 for ; Sun, 16 Jan 2022 02:03:03 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 7E8BA95AF8 for ; Sun, 16 Jan 2022 07:03:03 +0000 (UTC) X-FDA: 79035258246.25.31BD335 Received: from mail-qv1-f50.google.com (mail-qv1-f50.google.com [209.85.219.50]) by imf18.hostedemail.com (Postfix) with ESMTP id 0A8431C0007 for ; Sun, 16 Jan 2022 07:03:02 +0000 (UTC) Received: by mail-qv1-f50.google.com with SMTP id l13so13205943qvz.10 for ; Sat, 15 Jan 2022 23:03:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DFJxJo3WrNDOnKnM1u6xw8YsXtSt+iZ6G/kMCVsM30Y=; b=MxSg4cfCRB1PyF5rIDfg1wS+8LqSgSTjwIJRdmXpCkdG6tlGqKZRxGQ7JxJZzlRXGD /5w1EjxiJ8QO3PsTMwUnPpElPln6nUCAMQozzETox8Z81UOfKVKVpMWtWfTyr0xSiFqy m00x+pnqZzdgTk68hJ+KDg4m+dIbwxSuwvU0KeOLH7ncP9oT+b0PBxPp2fUduVIqtWXT d8hukUGdFLsXHfUX4pM2yTr/32mvufGdhaQtmNrliyUR5YCFwS1aAiwqdddo7emu4erd 1CjeZeI6UfOnLgR4xUA4k6w5jHVc3Y5H54Vy/lV1vxFBZiZSsd7iblTsJTlYajMkmA2F 4/tQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=DFJxJo3WrNDOnKnM1u6xw8YsXtSt+iZ6G/kMCVsM30Y=; b=4fjL2mKUFX0Z1YCW3rAH5ybww7ERET+BjvJ/bL7W7pDjUoqwS4I2QrQqQE8qFhjSd3 l+pKsiIbk8tyNehi0QqpERiNRt7ArziOMZmJsli1eCmr3blBNwdiiClNc1/0a71phM8R 0ASKvDDHrY9zuxfsI7z8jIlROiaNXnkYk6A9CU7Ee8h+FMiAhTYkQKqgDJVooIDyGJNg Ydq6EFHSYTzD8Md6By/nLm8lD2V8a3OReLu03ruBLO4YGpu2eZUZcS02fymOtHm3+QXF kddsEk0BZ2JFBYRJHfornuSKiOD9s9d2RRlWZRDpgJErR5kRDjTxwpuF1ywKyYooXdP2 XZCQ== X-Gm-Message-State: AOAM533jVnjuYbfFkLAHhNcPCURLy72IXpoqXtXJnDIk6rEXlVcuAcxX FSiaSXi+y+1mm8zg16ilQC8= X-Google-Smtp-Source: ABdhPJygxEjC1+1meJyj9mKP2pvI8gdBvMmwHd+nf7+dfOrEE4GD0d6YIvCRTYbe50Q4Fi1wSA+r0g== X-Received: by 2002:ad4:4ea6:: with SMTP id ed6mr7323176qvb.35.1642316582451; Sat, 15 Jan 2022 23:03:02 -0800 (PST) Received: from WRT-WX9.. ([207.246.89.135]) by smtp.gmail.com with ESMTPSA id ay21sm4703439qtb.12.2022.01.15.23.02.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 15 Jan 2022 23:03:02 -0800 (PST) From: Changbin Du To: Andrew Morton , "Matthew Wilcox (Oracle)" Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, Changbin Du Subject: [PATCH] mm: fix missed initialization for folio_batch::percpu_pvec_drained Date: Sun, 16 Jan 2022 15:02:27 +0800 Message-Id: <20220116070227.6854-1-changbin.du@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 0A8431C0007 X-Stat-Signature: 8977xjpdzzggjem8mjns16x8uukt7wu6 Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=MxSg4cfC; spf=pass (imf18.hostedemail.com: domain of changbin.du@gmail.com designates 209.85.219.50 as permitted sender) smtp.mailfrom=changbin.du@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-HE-Tag: 1642316582-189869 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: The folio_batch_init() forgets to initinize folio_batch::percpu_pvec_drained. This can be detected by UBSAN tool. [ 6.990914][ T1] ======================================================================== [ 6.991968][ T1] UBSAN: invalid-load in mm/swap.c:996:11 [ 6.993429][ T1] load of value 124 is not a valid value for type '_Bool' [ 6.994774][ T1] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 5.16.0-09673-ga33f5c380c4b #27 [ 6.995909][ T1] Hardware name: riscv-virtio,qemu (DT) [ 6.996898][ T1] Call Trace: [ 6.997608][ T1] [] dump_backtrace+0x30/0x38 [ 6.998307][ T1] [] dump_stack_lvl+0x58/0x7a [ 6.998822][ T1] [] dump_stack+0x18/0x20 [ 6.999334][ T1] [] ubsan_epilogue+0x10/0x58 [ 6.999938][ T1] [] __ubsan_handle_load_invalid_value+0x84/0x86 [ 7.000626][ T1] [] __pagevec_release+0x6c/0x72 [ 7.001212][ T1] [] truncate_inode_pages_range+0x152/0x4a6 [ 7.001839][ T1] [] truncate_inode_pages+0x22/0x2a [ 7.002397][ T1] [] blkdev_flush_mapping+0x78/0x13e [ 7.002960][ T1] [] blkdev_put+0x1a6/0x1f8 [ 7.003482][ T1] [] disk_scan_partitions+0x5c/0x78 [ 7.004069][ T1] [] device_add_disk+0x2a0/0x2c0 [ 7.004627][ T1] [] virtblk_probe+0x68c/0xb20 [ 7.005176][ T1] [] virtio_dev_probe+0x12e/0x210 [ 7.005718][ T1] [] really_probe.part.0+0x6c/0x24e [ 7.006266][ T1] [] __driver_probe_device+0xdc/0x13e [ 7.006847][ T1] [] driver_probe_device+0x40/0x10c [ 7.007451][ T1] [] __driver_attach+0x8c/0x172 [ 7.008036][ T1] [] bus_for_each_dev+0x6a/0xa8 [ 7.008617][ T1] [] driver_attach+0x2e/0x36 [ 7.009159][ T1] [] bus_add_driver+0x170/0x1ee [ 7.009717][ T1] [] driver_register+0x66/0xfe [ 7.010295][ T1] [] register_virtio_driver+0x30/0x4e [ 7.010899][ T1] [] init+0x78/0xac [ 7.011381][ T1] [] do_one_initcall+0x7e/0x262 [ 7.011955][ T1] [] kernel_init_freeable+0x30e/0x372 [ 7.012559][ T1] [] kernel_init+0x32/0x178 [ 7.013105][ T1] [] ret_from_exception+0x0/0x14 [ 7.015034][ T1] ======================================================================== Signed-off-by: Changbin Du --- include/linux/pagevec.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/pagevec.h b/include/linux/pagevec.h index dda8d5868c81..67b1246f136b 100644 --- a/include/linux/pagevec.h +++ b/include/linux/pagevec.h @@ -111,6 +111,7 @@ static_assert(offsetof(struct pagevec, pages) == static inline void folio_batch_init(struct folio_batch *fbatch) { fbatch->nr = 0; + fbatch->percpu_pvec_drained = false; } static inline unsigned int folio_batch_count(struct folio_batch *fbatch)