Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2134084pxb; Mon, 22 Feb 2021 22:13:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwzQTNfewjmpHgbqXjyusnYL6iFW59EwhQqSO7RgGVlZIfkQAWiqNXxEw4t2N8jIX2E8YpF X-Received: by 2002:a17:906:3acc:: with SMTP id z12mr25354189ejd.494.1614060839687; Mon, 22 Feb 2021 22:13:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614060839; cv=none; d=google.com; s=arc-20160816; b=vV7NjqIsgwJwPDlZ3sWzNHD2JTreOZX07aNS27VcyUp45SMjzYv4F9iMVVCjrpDf1I l8zKztZ3xzNlpFips27C7S9rP1/ea8RqpkCDnGidW8IbAMy9aAjwPevhjtZX0m5E+K3i +W/WrTEioOnktHfJXMFZPm5gGGgUqX54WiDOVK52gkrEOrGTQ62bHgJexGc318A5o5TY eQRBhK5avqXIhsXsXzcguG22VAJFcA+eueqIC85bM5y8JPwvZe1G6zYavHYcDSyfLi7f wfesxhoOEC4uN2VrgufGi5fjIiLXc6gf/dliTu9dMQEzEqs8hcKwhPsKuYeCzRIln/0V 0H6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=GyJORd7FWEZsXSaJofrLR3ruQAyi/9i2o1KfD9q8gl4=; b=NujyDuXzecya4Cq2e0W/Z4YgKs/R7OavaHCgz3ktS3x3JKlyqJw1aNqFAR5mzkZbsm w5wMyhuKfIbxqP828xie4EqdrlyXll6w9+qhx0HmWTaLWxxpIANMYXl0BinwVq0qQ7Yi Y7gOPeVb1X2eThi/BDjgMr5nJ1wrM+XNRFDVNp5XOuxBSodcSeKD5c/HaYn5qVt3XtN9 eqnNRSmT/0ESetAaU+NGS80vGpo8fIka3jXh9Abqs4mjjII5IlUIAHA9l1jqR9tPeY3L nTcVH7zmzlx2cd595bb3NSvNlHv+r/A8Xb/cjFbIQnagT5fXl88CZe+Yw9l5Ks2EIt9k Rc2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="udwJ/mPH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s11si7685314edr.584.2021.02.22.22.13.21; Mon, 22 Feb 2021 22:13:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="udwJ/mPH"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230362AbhBWEXF (ORCPT + 99 others); Mon, 22 Feb 2021 23:23:05 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230334AbhBWEXF (ORCPT ); Mon, 22 Feb 2021 23:23:05 -0500 Received: from mail-lf1-x134.google.com (mail-lf1-x134.google.com [IPv6:2a00:1450:4864:20::134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83262C06174A for ; Mon, 22 Feb 2021 20:22:24 -0800 (PST) Received: by mail-lf1-x134.google.com with SMTP id p21so9152586lfu.11 for ; Mon, 22 Feb 2021 20:22:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=GyJORd7FWEZsXSaJofrLR3ruQAyi/9i2o1KfD9q8gl4=; b=udwJ/mPHPi6kGHPc4qGwVsZe+0iq6dfraQjjZ1IeOVNbsgZ3Q7jzZq7VxPA1cjlrfo WrmCEkFMHiUl8Mb2v/hzLdsPKOpL3aSHA29CTSo1n6s9xjFCvfvzIVZNlYveNBEIqGul slceZzVzPGAfvOnvZrnSBrllQvbgwaOdS1AEYEkIC1X4HiGiQOpTESMUvqUx77GHl5IG /URO2gpIraDRfU2rc3sJGttZYGpDywPZDbYaamGRhezsHeyn+CM1/ahdjvlaOfSJYjtZ 85rz7B0FdL+rpTuG/s1mUBSoDu9+9kARPESxrxzNH0JnO820Ru0vPVr1mhuKItn5Dk0K 5riw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=GyJORd7FWEZsXSaJofrLR3ruQAyi/9i2o1KfD9q8gl4=; b=se13H4yYnR3PaIRX2fJuE0KHKCvefmJK3z+uKoEMo1CX1Kb/O/CGl2bsta0qbPi8gY mc8c8ayzo5CPFhk9QAWagWWhi7c/94slYMwQ9lGRwN7hmhbLE0F46YC5XK3Z5fzCiEIv 4flwaEiVd9EKteFcC2M2+T1gZQZ6kzOVIxVG2oqX185he7IKUBIb1NxQgX5FdYH7snUu qCxtP7sin4Wjq2EsFRAW4hxRz8LJEXeZHzL1Iu3d43xKv2GodS9eU9B/EN8Lut6pQGv8 O+d31E3xvXMnD1vY1TlYg7nZ0xfhc+8d+PZRjw/dS00dRTLptulIIJpQpWDVTCdfBGBa 4twg== X-Gm-Message-State: AOAM533KEgvQO16cbtfMLedIswmCYhG7JBTERRVEmhWW9KeSajq5xCxO UU5mk2tGJcgqaqe4ni/jtx4HIJjXRq+5kiPpFpuGFA== X-Received: by 2002:a05:6512:33b8:: with SMTP id i24mr15205981lfg.7.1614054142873; Mon, 22 Feb 2021 20:22:22 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: John Stultz Date: Mon, 22 Feb 2021 20:22:09 -0800 Message-ID: Subject: Re: [REGRESSION] "split bio_kmalloc from bio_alloc_bioset" causing crash shortly after bootup To: Chaitanya Kulkarni Cc: David Anderson , Christoph Hellwig , Johannes Thumshirn , Damien Le Moal , Jens Axboe , Alistair Delva , Todd Kjos , Amit Pundir , YongQin Liu , lkml , "linux-block@vger.kernel.org" Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 22, 2021 at 7:39 PM Chaitanya Kulkarni wrote: > > On 2/22/21 19:07, John Stultz wrote: > > [ 34.784901] ueventd: LoadWithAliases was unable to load platform:regulatory > > [ 34.785313] bio_alloc_bioset+0x14/0x230 > > [ 34.796189] bio_clone_fast+0x28/0x80 > > [ 34.799848] bio_split+0x50/0xd0 > > [ 34.803072] blk_crypto_fallback_encrypt_bio+0x2ec/0x5e8 > > [ 34.808384] blk_crypto_fallback_bio_prep+0xfc/0x140 > > [ 34.813345] __blk_crypto_bio_prep+0x13c/0x150 > > [ 34.817784] submit_bio_noacct+0x3c0/0x548 > > [ 34.821880] submit_bio+0x48/0x200 > > [ 34.825278] ext4_io_submit+0x50/0x68 > > [ 34.828939] ext4_writepages+0x558/0xca8 > > [ 34.832860] do_writepages+0x58/0x108 > > [ 34.836522] __writeback_single_inode+0x44/0x510 > > [ 34.841137] writeback_sb_inodes+0x1e0/0x4a8 > > [ 34.845404] __writeback_inodes_wb+0x78/0xe8 > > [ 34.849670] wb_writeback+0x274/0x3e8 > > [ 34.853328] wb_workfn+0x308/0x5f0 > > [ 34.856726] process_one_work+0x1ec/0x4d0 > > [ 34.860734] worker_thread+0x44/0x478 > > [ 34.864392] kthread+0x140/0x150 > > [ 34.867618] ret_from_fork+0x10/0x30 > > [ 34.871197] Code: a9ba7bfd 910003fd f9000bf3 7900bfa1 (f9403441) > > [ 34.877289] ---[ end trace e6c2a3ab108278f0 ]--- > > [ 34.893636] Kernel panic - not syncing: Oops: Fatal exception > > > > If you have time then until you get the reply from others, can you try > following patch ? > > diff --git a/block/bio.c b/block/bio.c > index a1c4d2900c7a..9976400ec66a 100644 > --- a/block/bio.c > +++ b/block/bio.c > @@ -663,7 +663,10 @@ struct bio *bio_clone_fast(struct bio *bio, gfp_t > gfp_mask, struct bio_set *bs) > { > struct bio *b; > > - b = bio_alloc_bioset(gfp_mask, 0, bs); > + if (bs) > + b = bio_alloc_bioset(gfp_mask, 0, bs); > + else > + b = bio_kmalloc(gfp_mask, 0); > if (!b) > return NULL; > > P.S.This is purely based on the code inspection and it may not solve your > issue. Proceed with the caution as it may *break* your system. So with an initial quick test, this patch (along with the follow-on one you sent) seems to avoid the issue. I'm wondering if given there are multiple call sites, that in bio_alloc_bioset() would something like the following make more sense? (apologies, copy pasted so this is whitespace corrupted) thanks -john diff --git a/block/bio.c b/block/bio.c index a1c4d2900c7a..391d5cde79fc 100644 --- a/block/bio.c +++ b/block/bio.c @@ -402,6 +402,9 @@ struct bio *bio_alloc_bioset(gfp_t gfp_mask, unsigned short nr_iovecs, struct bio *bio; void *p; + if(!bs) + return bio_kmalloc(gfp_mask, 0); + /* should not use nobvec bioset for nr_iovecs > 0 */ if (WARN_ON_ONCE(!mempool_initialized(&bs->bvec_pool) && nr_iovecs > 0)) return NULL;