Received: by 10.192.165.156 with SMTP id m28csp1147124imm; Wed, 11 Apr 2018 13:19:13 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/SSKnk/AUiNvMY3/9xcejCUm7/d5q91JYjyqk0sF8bQNpK8OmtgDvVWLsxvaww13vbVJN1 X-Received: by 10.167.133.23 with SMTP id v23mr5173612pfn.157.1523477952967; Wed, 11 Apr 2018 13:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523477952; cv=none; d=google.com; s=arc-20160816; b=SEtiYSm8BK0wzK37rFoIcMl+lLLTHo5kJS0Sk2xcppcc8A/uE7WurVvqK2vff0ELiD QVoQffpXmh4wn+1iInH13OzqohR75BQAZadrYxv7DeXNdt4JUVXPN8i4Sxnct4M3JLAA qjbmL+R/39ahPcjIyXJhNWh2GAlkS/YxgH1Gghyk4tWtGZUPrIq0KOSn0ANTe+7Z3rPy Y+oL+ZeV31NpJ/1E9P0jWvxF9IOxm1XeTghKtFOQwHSBKVnDEVNZXTH2t8GgmCbcxK/9 e8XvuQMuNmV8s7SqEjP0CSLpPRkpqvKKXDk1yteB46RgRn89aa1PidNtnAu5gmJ35FPc JmOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=nGZx5UD9oXZBtMv7POLy3iOkEqW/Zw4ZG4KQCh+usGQ=; b=Na4XWBK0j7vlyyAGyfperzL1ePHiBFR3ln5/T1uUWLUhpQZH9seReLTpgVGeHWTZK6 mNKGVVecjQ68L+B3yV4nf5RjsINHDT01TGvrMecTxrUVph3c1fAxhE7BuQhLVX6y4krC HPrVQ6keidDmS1OCQCIkTlBceMC3Stw/Xm/tW0q8+H7BBRbE+7bRC2kfOnvkZx3Qlv2N l9d6lUOsstw+9A08yLlAbyESmedC3P8Pvo3fybwqZnfQqgKYzq0zq+qkZI8NUupDMHu7 GP2mDGS7DWrYQKLgXzr/We2b0SeOPgMrmcy9uE8wPVlnbIAi5J/qpJp2SzCFECgZCtxM prDQ== ARC-Authentication-Results: i=1; mx.google.com; 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 q61-v6si1721964plb.729.2018.04.11.13.18.36; Wed, 11 Apr 2018 13:19:12 -0700 (PDT) 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; 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 S1757039AbeDKUN2 (ORCPT + 99 others); Wed, 11 Apr 2018 16:13:28 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:33928 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933337AbeDKSxo (ORCPT ); Wed, 11 Apr 2018 14:53:44 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4E9EEEAD; Wed, 11 Apr 2018 18:53:43 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alexander GQ Gerasiov , Julia Cartwright , Shaohua Li , Sasha Levin Subject: [PATCH 4.9 003/310] md/raid5: make use of spin_lock_irq over local_irq_disable + spin_lock Date: Wed, 11 Apr 2018 20:32:22 +0200 Message-Id: <20180411183622.442074804@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Julia Cartwright [ Upstream commit 3d05f3aed5d721c2c77d20288c29ab26c6193ed5 ] On mainline, there is no functional difference, just less code, and symmetric lock/unlock paths. On PREEMPT_RT builds, this fixes the following warning, seen by Alexander GQ Gerasiov, due to the sleeping nature of spinlocks. BUG: sleeping function called from invalid context at kernel/locking/rtmutex.c:993 in_atomic(): 0, irqs_disabled(): 1, pid: 58, name: kworker/u12:1 CPU: 5 PID: 58 Comm: kworker/u12:1 Tainted: G W 4.9.20-rt16-stand6-686 #1 Hardware name: Supermicro SYS-5027R-WRF/X9SRW-F, BIOS 3.2a 10/28/2015 Workqueue: writeback wb_workfn (flush-253:0) Call Trace: dump_stack+0x47/0x68 ? migrate_enable+0x4a/0xf0 ___might_sleep+0x101/0x180 rt_spin_lock+0x17/0x40 add_stripe_bio+0x4e3/0x6c0 [raid456] ? preempt_count_add+0x42/0xb0 raid5_make_request+0x737/0xdd0 [raid456] Reported-by: Alexander GQ Gerasiov Tested-by: Alexander GQ Gerasiov Signed-off-by: Julia Cartwright Signed-off-by: Shaohua Li Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/md/raid5.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c @@ -110,8 +110,7 @@ static inline void unlock_device_hash_lo static inline void lock_all_device_hash_locks_irq(struct r5conf *conf) { int i; - local_irq_disable(); - spin_lock(conf->hash_locks); + spin_lock_irq(conf->hash_locks); for (i = 1; i < NR_STRIPE_HASH_LOCKS; i++) spin_lock_nest_lock(conf->hash_locks + i, conf->hash_locks); spin_lock(&conf->device_lock); @@ -121,9 +120,9 @@ static inline void unlock_all_device_has { int i; spin_unlock(&conf->device_lock); - for (i = NR_STRIPE_HASH_LOCKS; i; i--) - spin_unlock(conf->hash_locks + i - 1); - local_irq_enable(); + for (i = NR_STRIPE_HASH_LOCKS - 1; i; i--) + spin_unlock(conf->hash_locks + i); + spin_unlock_irq(conf->hash_locks); } /* bio's attached to a stripe+device for I/O are linked together in bi_sector @@ -732,12 +731,11 @@ static bool is_full_stripe_write(struct static void lock_two_stripes(struct stripe_head *sh1, struct stripe_head *sh2) { - local_irq_disable(); if (sh1 > sh2) { - spin_lock(&sh2->stripe_lock); + spin_lock_irq(&sh2->stripe_lock); spin_lock_nested(&sh1->stripe_lock, 1); } else { - spin_lock(&sh1->stripe_lock); + spin_lock_irq(&sh1->stripe_lock); spin_lock_nested(&sh2->stripe_lock, 1); } } @@ -745,8 +743,7 @@ static void lock_two_stripes(struct stri static void unlock_two_stripes(struct stripe_head *sh1, struct stripe_head *sh2) { spin_unlock(&sh1->stripe_lock); - spin_unlock(&sh2->stripe_lock); - local_irq_enable(); + spin_unlock_irq(&sh2->stripe_lock); } /* Only freshly new full stripe normal write stripe can be added to a batch list */