From patchwork Thu Jun 7 15:40:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jens Axboe X-Patchwork-Id: 10452867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7A67C60467 for ; Thu, 7 Jun 2018 15:40:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69C75298F3 for ; Thu, 7 Jun 2018 15:40:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5DF95298F9; Thu, 7 Jun 2018 15:40:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 493A7298FD for ; Thu, 7 Jun 2018 15:40:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933076AbeFGPkw (ORCPT ); Thu, 7 Jun 2018 11:40:52 -0400 Received: from mail-io0-f196.google.com ([209.85.223.196]:42841 "EHLO mail-io0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933293AbeFGPku (ORCPT ); Thu, 7 Jun 2018 11:40:50 -0400 Received: by mail-io0-f196.google.com with SMTP id r24-v6so12318057ioh.9 for ; Thu, 07 Jun 2018 08:40:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20150623.gappssmtp.com; s=20150623; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=AzB4mKghjlUely1Xj4tIjGFmKM06NfuYTm0G1lDzqRc=; b=KMF5ZZP5TTHHAunOSG+nx7ik183U/03BBLnfjnx/egUJJZ4DEkJJWmIKJRgK4i2N00 P7YEfbunm7RNMkLD5BQkB0IuXE4PJmvtEEpyagXLOHswG5aKbzazLgCtrbK1CuZj5KsK 7WdBE7+ts4UPZGtqHX8Ckb9/awB13EH7CdD6M1RqqbOE2TgyWdR27lDsiLKESGrXMe4A EwguWv7pCsGsE3JxsrJz5UhDWWXX52VAw9Fqsm2ifct7P6CO3d0CqCPXKF6wm/feetqX rgFLUNSOBzdzD63mPWy2BvlX+VMrlqhEqqE5iOaXTa7QD6UP583g+1NDuGnbsb1Z87xF Fw+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=AzB4mKghjlUely1Xj4tIjGFmKM06NfuYTm0G1lDzqRc=; b=UuLRJtx+s4hu7brEyFEMXD6PrdUTiKpap1XRRZfn9c29kzwkj29iBG7d7n5VY3IS7Z eMTAHEKw19bkBcdiNJecZgQTS4BG+8Blp0cCV0kBzQEs+MiifBrjf6v08y2O8gvjJiPy hUrazc5G/PQAi5BbfeeLlbJyXnx9UTfxJpgy5QYsrqcgS1rzzOO139H509UVCZcoiEAl fgFjtDL074/2VCBd3Svw6UsTF7naF6kIDESWXhWLX3LpksAXfCsMbO248F2NUJBxHq9G 3TLtDyIsC+whoViEamg1giMKryPMWMNJLETm0hmYtaPorpNyS7AqT+lWktRX6GdKRugd 8RJA== X-Gm-Message-State: APt69E14t4kFLEcRMc9bIDnHHyj1SSQmccZ9MsN236773bLQc4f7ut+o suVe0gRRbs1NuNZ29dxPj0Yl2w== X-Google-Smtp-Source: ADUXVKJyvUQEkEVHzNqvxHoC4la3VWieGycazbKPMNgylurlt/qoEzhbU9rYnlTGOM1Zs/9XBupEvA== X-Received: by 2002:a6b:b68a:: with SMTP id g132-v6mr1981068iof.209.1528386049625; Thu, 07 Jun 2018 08:40:49 -0700 (PDT) Received: from [192.168.1.167] ([216.160.245.98]) by smtp.gmail.com with ESMTPSA id f193-v6sm921873itf.9.2018.06.07.08.40.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 08:40:48 -0700 (PDT) Subject: Re: Fwd: [powerpc/Baremetal]Kernel OOPS while executing memory hotplug on Power8 baremetal From: Jens Axboe To: vrbagal1 , Bart Van Assche , kent.overstreet@gmail.com, snitzer@redhat.com, linux-block@vger.kernel.org Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, sachinp@linux.vnet.ibm.com, Linuxppc-dev References: <042fc8ee69b74c57815c0edfdbb253495e9d7718.camel@wdc.com> Message-ID: Date: Thu, 7 Jun 2018 09:40:47 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On 6/7/18 8:45 AM, Jens Axboe wrote: > On 6/7/18 4:37 AM, vrbagal1 wrote: >> On 2018-06-07 13:12, Bart Van Assche wrote: >>> On Thu, 2018-06-07 at 12:56 +0530, Venkat Rao B wrote: >>>> On Thursday 07 June 2018 12:46 PM, Bart Van Assche wrote: >>>>> On Thu, 2018-06-07 at 12:38 +0530, vrbagal1 wrote: >>>>>> Observing Kernel oops and machine reboots while executing memory hotplug >>>>>> test case, on Power8 Baremetal machine. >>>>>> >>>>>> I see this is introduced some where between rc6 and 4.17. >>>>> >>>>> Please provide the exact versions (git commit IDs) of the kernel versions >>>>> you have tested. >>>> >>>> Commit Id ---> 5037be168f >>> >>> The reason I was asking for the commit ID is because I saw that >>> clone_endio() >>> occurs in the oops which means that the dm driver is involved. An >>> important fix >>> for the dm driver went upstream recently, namely d37753540568 ("dm: Use >>> kzalloc >>> for all structs with embedded biosets/mempools"). Can you double check >>> whether >>> that commit it present in your tree? If it is not present, please >>> update to the >>> latest master and retest. If it is present, please report how to >>> reproduce >>> this oops to Kent Overstreet, Jens Axboe, linux-block and Mike Snitzer. >>> >>> Thanks, >>> >>> Bart. >> >> >> Yes, the fix is present in the tree, which I have tested. >> >> Steps to reproduce: >> >> Step1: Clone and Install avocado git clone >> https://github.com/avocado-framework/avocado.git >> Step2: Clone >> https://github.com/avocado-framework-tests/avocado-misc-tests.git >> Test case is >> https://github.com/avocado-framework-tests/avocado-misc-tests/blob/master/memory/memhotplug.py >> Step3: Command to run the test is avocado run >> avocado-misc-tests/memory/memhotplug.py > > Can you try with the below? Not a fully formed fix since I'd prefer > if the dm bioset copy stuff was changed instead, but worth a shot. This is closer to an actual fix, please try that instead. diff --git a/block/bio.c b/block/bio.c index 595663e0281a..0616d86b15c6 100644 --- a/block/bio.c +++ b/block/bio.c @@ -1967,6 +1967,21 @@ int bioset_init(struct bio_set *bs, } EXPORT_SYMBOL(bioset_init); +int bioset_init_from_src(struct bio_set *new, struct bio_set *src) +{ + unsigned int pool_size = src->bio_pool.min_nr; + int flags; + + flags = 0; + if (src->bvec_pool.min_nr) + flags |= BIOSET_NEED_BVECS; + if (src->rescue_workqueue) + flags |= BIOSET_NEED_RESCUER; + + return bioset_init(new, pool_size, src->front_pad, flags); +} +EXPORT_SYMBOL(bioset_init_from_src); + #ifdef CONFIG_BLK_CGROUP /** diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 98dff36b89a3..20a8d63754bf 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c @@ -1953,9 +1953,10 @@ static void free_dev(struct mapped_device *md) kvfree(md); } -static void __bind_mempools(struct mapped_device *md, struct dm_table *t) +static int __bind_mempools(struct mapped_device *md, struct dm_table *t) { struct dm_md_mempools *p = dm_table_get_md_mempools(t); + int ret = 0; if (dm_table_bio_based(t)) { /* @@ -1982,13 +1983,16 @@ static void __bind_mempools(struct mapped_device *md, struct dm_table *t) bioset_initialized(&md->bs) || bioset_initialized(&md->io_bs)); - md->bs = p->bs; - memset(&p->bs, 0, sizeof(p->bs)); - md->io_bs = p->io_bs; - memset(&p->io_bs, 0, sizeof(p->io_bs)); + ret = bioset_init_from_src(&md->bs, &p->bs); + if (ret) + goto out; + ret = bioset_init_from_src(&md->io_bs, &p->io_bs); + if (ret) + bioset_exit(&md->bs); out: /* mempool bind completed, no longer need any mempools in the table */ dm_table_free_md_mempools(t); + return ret; } /* @@ -2033,6 +2037,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, struct request_queue *q = md->queue; bool request_based = dm_table_request_based(t); sector_t size; + int ret; lockdep_assert_held(&md->suspend_lock); @@ -2068,7 +2073,11 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, md->immutable_target = dm_table_get_immutable_target(t); } - __bind_mempools(md, t); + ret = __bind_mempools(md, t); + if (ret) { + old_map = ERR_PTR(ret); + goto out; + } old_map = rcu_dereference_protected(md->map, lockdep_is_held(&md->suspend_lock)); rcu_assign_pointer(md->map, (void *)t); @@ -2078,6 +2087,7 @@ static struct dm_table *__bind(struct mapped_device *md, struct dm_table *t, if (old_map) dm_sync_table(md); +out: return old_map; } diff --git a/include/linux/bio.h b/include/linux/bio.h index 810a8bee8f85..307682ac2f31 100644 --- a/include/linux/bio.h +++ b/include/linux/bio.h @@ -417,6 +417,7 @@ enum { extern int bioset_init(struct bio_set *, unsigned int, unsigned int, int flags); extern void bioset_exit(struct bio_set *); extern int biovec_init_pool(mempool_t *pool, int pool_entries); +extern int bioset_init_from_src(struct bio_set *new, struct bio_set *src); extern struct bio *bio_alloc_bioset(gfp_t, unsigned int, struct bio_set *); extern void bio_put(struct bio *);