Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1611662ybc; Wed, 13 Nov 2019 01:21:36 -0800 (PST) X-Google-Smtp-Source: APXvYqyvZfXTL3qW2TcQehEf7XuoSkKpZliusCydkjuoXbaXodw+wY73f1bClyMOpZ7XNBlU6ivH X-Received: by 2002:aa7:dbd4:: with SMTP id v20mr2504083edt.58.1573636896077; Wed, 13 Nov 2019 01:21:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573636896; cv=none; d=google.com; s=arc-20160816; b=t5kkQt/hmEVkgbizX+bAhg5zYJLzX4u0qfunCERrC/jJeabyaA1AplqXIHBujC2y6v Blyw/ud3SIZep7uxK0lhJCy5IFN0LoMIzRMq6t6oXeUMKv6gZwuUL8ckBFhrgIuh3KP3 rAJclg3fCE41nQDiG6XozDG0upZ220cw/VCmQG733JFbJEkVzWF3QQ4h6F4HXun3dJdv TU4wZvroz/DFlApzpFSuZAqOEQf8L6/pJc7dN4Q9yq6ofGH7jUbbu/C9vI10lkY/tqIw 0PA16QyNx5aRhkJPXf5GcqWBaB+Rm7eJd7RgllxKCUYnYYVjbgFvmXd7Gfwn8LWvqPS7 kHrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=oIUwVCoXTRy2Xzc2WTbShQwLgC231DhggYOStvhTE1g=; b=D1RS1hTvtKEVbNFhBZnXQQWp1PdwSUKyVigYsSSE7LghZji8yfPdM5C47zA/7pYa0J /iZN44cvLHtPsLL0ej2hM7uIUeWATSLKUfNUA+EW8uwdfMF1/Clp2P2EOpia667SQSLv pEkpQbjYgMTwieVvfgrtDuWWt7l57SlVSfnlSPuHWg3I1upUpDNdcEdZtMW+aloch1ml +BhHIlY/CyKPUEnAVmCEIddhJ5ag2gM0QBgP329Rbfv/yer0HqXUHftshD+nP1dWigoq 5FzeO+HajECHE5vjXwSMSyBHDkK2d4IkAtXCdR6BwQrl1XqaqE8MKVaJd1FC/aRCmkSD mbag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arrikto-com.20150623.gappssmtp.com header.s=20150623 header.b=lSx2xsky; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l19si942486edj.414.2019.11.13.01.21.11; Wed, 13 Nov 2019 01:21:36 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@arrikto-com.20150623.gappssmtp.com header.s=20150623 header.b=lSx2xsky; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbfKMJUk (ORCPT + 99 others); Wed, 13 Nov 2019 04:20:40 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:39320 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726952AbfKMJUk (ORCPT ); Wed, 13 Nov 2019 04:20:40 -0500 Received: by mail-lj1-f194.google.com with SMTP id p18so1718168ljc.6 for ; Wed, 13 Nov 2019 01:20:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arrikto-com.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=oIUwVCoXTRy2Xzc2WTbShQwLgC231DhggYOStvhTE1g=; b=lSx2xskyZOQ4nh+qgQles1LugvACmjIDL4+NSPQoZ0lftWJM0Yz7BGSwn8J/e65eHj fNkcUkR4tIE3elCZ/uAQNqDd19xusilTspuDXzLr/uFrfkTD+EoNbwLyS/618zlav+Xi iRxLIGgp0zqdPG0k9Y4xmbnddDGRDNExZLiP1cTsNuGbR0uWoWaCCTUsK++TihJky9LA wZcBtOqotrhrj4DPLxCP5PCq1uCAvjdD9SEjZe1Du88F4WH1ZyY6x2Woi0fxeVZtfdkh dlb9Oaxx8wgfRDE6HWE7X3FQO0cH40SZ5W0ZB4BJPinujmePJtoVoKnRXASYIfQhqNIm maeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=oIUwVCoXTRy2Xzc2WTbShQwLgC231DhggYOStvhTE1g=; b=Q78ncH4FHi6tvwPNOwKWCQO0f5NqfzxYNheyJcVfFtJMTchS2M6QXulCO/Y9PuGcXb iDJ0pyx8F0CIeuN3RLJ0hthcS1m0xojS9dgBbMOa1mFkwQMsapmlR9aXqLiK7ZHkCtZ/ dxWkjDpb8gYOBNsWwIJkgugY35a1AfiAsL+5NDV0p4RgFs4UGm173xME/e6i18ImEv9D Il8vQT50eS8O0cHMBA1t5dyZuwV+pf9EZA/x+YF1R++MNLyvfFUHCpkNbSoTQspL3zZx mHOvLJZHeGFHDk+D5iR3ZzEUMg18r61ajlkDocI05M8d+xifqqK9tYcUGBQK9ReM5daf hD0w== X-Gm-Message-State: APjAAAX1FqE+a6KS+KCu3boPg6BKIMmzwy8o60Rq22L9fuX+7OVsdcMv eVpDa7P274qWW7If5pmuQcLhkwjVwnU= X-Received: by 2002:a2e:9d8d:: with SMTP id c13mr1589644ljj.71.1573636838399; Wed, 13 Nov 2019 01:20:38 -0800 (PST) Received: from [10.94.250.119] ([31.177.62.212]) by smtp.gmail.com with ESMTPSA id 3sm683657lfq.55.2019.11.13.01.20.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 01:20:37 -0800 (PST) Subject: Re: [PATCH RT 1/2 v2] dm-snapshot: fix crash with the realtime kernel To: Mikulas Patocka , Mike Snitzer Cc: Scott Wood , Ilias Tsitsimpis , dm-devel@redhat.com, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Daniel Wagner , Sebastian Andrzej Siewior , linux-rt-users@vger.kernel.org, tglx@linutronix.de References: From: Nikos Tsironis Message-ID: Date: Wed, 13 Nov 2019 11:20:35 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/12/19 6:09 PM, Mikulas Patocka wrote: > Snapshot doesn't work with realtime kernels since the commit f79ae415b64c. > hlist_bl is implemented as a raw spinlock and the code takes two non-raw > spinlocks while holding hlist_bl (non-raw spinlocks are blocking mutexes > in the realtime kernel). > > We can't change hlist_bl to use non-raw spinlocks, this triggers warnings > in dentry lookup code, because the dentry lookup code uses hlist_bl while > holding a seqlock. > > This patch fixes the problem by using non-raw spinlock > exception_table_lock instead of the hlist_bl lock. > > Signed-off-by: Mikulas Patocka > Fixes: f79ae415b64c ("dm snapshot: Make exception tables scalable") > Reviewed-by: Nikos Tsironis > --- > drivers/md/dm-snap.c | 23 +++++++++++++++++++++++ > 1 file changed, 23 insertions(+) > > Index: linux-2.6/drivers/md/dm-snap.c > =================================================================== > --- linux-2.6.orig/drivers/md/dm-snap.c 2019-11-12 16:44:36.000000000 +0100 > +++ linux-2.6/drivers/md/dm-snap.c 2019-11-12 17:01:46.000000000 +0100 > @@ -141,6 +141,10 @@ struct dm_snapshot { > * for them to be committed. > */ > struct bio_list bios_queued_during_merge; > + > +#ifdef CONFIG_PREEMPT_RT_BASE > + spinlock_t exception_table_lock; > +#endif > }; > > /* > @@ -625,30 +629,46 @@ static uint32_t exception_hash(struct dm > > /* Lock to protect access to the completed and pending exception hash tables. */ > struct dm_exception_table_lock { > +#ifndef CONFIG_PREEMPT_RT_BASE > struct hlist_bl_head *complete_slot; > struct hlist_bl_head *pending_slot; > +#else > + spinlock_t *lock; > +#endif > }; > > static void dm_exception_table_lock_init(struct dm_snapshot *s, chunk_t chunk, > struct dm_exception_table_lock *lock) > { > +#ifndef CONFIG_PREEMPT_RT_BASE > struct dm_exception_table *complete = &s->complete; > struct dm_exception_table *pending = &s->pending; > > lock->complete_slot = &complete->table[exception_hash(complete, chunk)]; > lock->pending_slot = &pending->table[exception_hash(pending, chunk)]; > +#else > + lock->lock = &s->exception_table_lock; > +#endif > } > > static void dm_exception_table_lock(struct dm_exception_table_lock *lock) > { > +#ifndef CONFIG_PREEMPT_RT_BASE > hlist_bl_lock(lock->complete_slot); > hlist_bl_lock(lock->pending_slot); > +#else > + spin_lock(lock->lock); > +#endif > } > > static void dm_exception_table_unlock(struct dm_exception_table_lock *lock) > { > +#ifndef CONFIG_PREEMPT_RT_BASE > hlist_bl_unlock(lock->pending_slot); > hlist_bl_unlock(lock->complete_slot); > +#else > + spin_unlock(lock->lock); > +#endif > } > > static int dm_exception_table_init(struct dm_exception_table *et, > @@ -1318,6 +1338,9 @@ static int snapshot_ctr(struct dm_target > s->first_merging_chunk = 0; > s->num_merging_chunks = 0; > bio_list_init(&s->bios_queued_during_merge); > +#ifdef CONFIG_PREEMPT_RT_BASE > + spin_lock_init(&s->exception_table_lock); > +#endif > > /* Allocate hash table for COW data */ > if (init_hash_tables(s)) { >