Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5371637imm; Tue, 18 Sep 2018 08:30:24 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYcXZ4f4ew2NW9HgryLOtca7c711Ur6s0V/JO4g0S8CWEOzScM9GclMUHAIN8fEZuRbe46k X-Received: by 2002:a63:ab0c:: with SMTP id p12-v6mr28982461pgf.190.1537284623877; Tue, 18 Sep 2018 08:30:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537284623; cv=none; d=google.com; s=arc-20160816; b=Cvw2gTgTFSEAEPnK7YjfbJQgsW0+ZMgT+6dGbzfG+Ap0QIqseFawEkeUijRrQcI00i bE06ZkPNwFN0se/QhEdQn+2F4q82ytWaAedXOvPA4wst87ocWT/Bm/De2qP33/PUDG4L eCoBt05ZcM6WGJKTK/jg1l0Os8k2GJoqJXF0G2HAhc3FabwnfboJgbH7qgIZTRTDBIA3 l286enkeChWgMN9jxzxUqIr8M8hhxKDwWMsrjgyxqoIWvDxAGyAsIxJJYRVIhl69jkyi F9X79hioAEg0+au0jaPQZro1oxaa4ri0h/iYszulj7/7PEjGWG2yRfaY4RgFxggXf056 R3Kw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from; bh=RHPCtKvMfqhL2Jul1oxgFPePmrPBOWf6jc9BJ5P9ZJI=; b=TWXN/wc2wezSMb82BjJvcEttcNyhG3DjX9gE2P1za3LAuH6V5rE5S6FRHswVetBV0c EWK/ld0X6J7sn4uI1RnVc8E9wzov1xBDcFf1tNJ+FiNV8XN9cI5iuANTXxDwSwZXKDL/ 6hMdpToIp9KMYgN4X8zcYwhDdXx3jVsASdmaK1Ozh/JbTKoIOoHiwTrXMfhOqgMNfra2 NniyPvyXMOKfiijborpYQd5ueQ9dqZdRAAltRIdjgsOqEOOemJT1f+n3AOJu93B9w0oj Y6yN+wwEG1GZWIYOTNmVPNTW6zP2T8Lvf9BEEEnPGiOoFYyYJijr/zLf1v6y1T3WtGPA uBzA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5-v6si17938069ply.193.2018.09.18.08.30.07; Tue, 18 Sep 2018 08:30:23 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729955AbeIRVCh (ORCPT + 99 others); Tue, 18 Sep 2018 17:02:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:46292 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727756AbeIRVCh (ORCPT ); Tue, 18 Sep 2018 17:02:37 -0400 Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2FEF37F6CB; Tue, 18 Sep 2018 15:29:32 +0000 (UTC) Received: from tagon.redhat.com (ovpn-118-14.phx2.redhat.com [10.3.118.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC36088EB2; Tue, 18 Sep 2018 15:29:31 +0000 (UTC) From: Clark Williams To: Sebastian Andrzej Siewior Cc: linux-kernel@vger.kernel.org, linux-rt-users@vger.kernel.org Subject: [PATCH RT] rt: convert mm/kasan/quarantine_lock to raw_spinlock Date: Tue, 18 Sep 2018 10:29:31 -0500 Message-Id: <20180918152931.17322-1-williams@redhat.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 18 Sep 2018 15:29:32 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The static lock quarantine_lock is used in mm/kasan/quarantine.c to protect the quarantine queue datastructures. It is taken inside quarantine queue manipulation routines (quarantine_put(), quarantine_reduce() and quarantine_remove_cache()), with IRQs disabled. This is no problem on a stock kernel but is problematic on an RT kernel where spin locks are converted to rt_mutex_t, which can sleep. Convert the quarantine_lock to a raw spinlock. The usage of quarantine_lock is confined to quarantine.c and the work performed while the lock is held is limited. Signed-off-by: Clark Williams --- mm/kasan/quarantine.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/mm/kasan/quarantine.c b/mm/kasan/quarantine.c index 3a8ddf8baf7d..b209dbaefde8 100644 --- a/mm/kasan/quarantine.c +++ b/mm/kasan/quarantine.c @@ -103,7 +103,7 @@ static int quarantine_head; static int quarantine_tail; /* Total size of all objects in global_quarantine across all batches. */ static unsigned long quarantine_size; -static DEFINE_SPINLOCK(quarantine_lock); +static DEFINE_RAW_SPINLOCK(quarantine_lock); DEFINE_STATIC_SRCU(remove_cache_srcu); /* Maximum size of the global queue. */ @@ -190,7 +190,7 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) if (unlikely(q->bytes > QUARANTINE_PERCPU_SIZE)) { qlist_move_all(q, &temp); - spin_lock(&quarantine_lock); + raw_spin_lock(&quarantine_lock); WRITE_ONCE(quarantine_size, quarantine_size + temp.bytes); qlist_move_all(&temp, &global_quarantine[quarantine_tail]); if (global_quarantine[quarantine_tail].bytes >= @@ -203,7 +203,7 @@ void quarantine_put(struct kasan_free_meta *info, struct kmem_cache *cache) if (new_tail != quarantine_head) quarantine_tail = new_tail; } - spin_unlock(&quarantine_lock); + raw_spin_unlock(&quarantine_lock); } local_irq_restore(flags); @@ -230,7 +230,7 @@ void quarantine_reduce(void) * expected case). */ srcu_idx = srcu_read_lock(&remove_cache_srcu); - spin_lock_irqsave(&quarantine_lock, flags); + raw_spin_lock_irqsave(&quarantine_lock, flags); /* * Update quarantine size in case of hotplug. Allocate a fraction of @@ -254,7 +254,7 @@ void quarantine_reduce(void) quarantine_head = 0; } - spin_unlock_irqrestore(&quarantine_lock, flags); + raw_spin_unlock_irqrestore(&quarantine_lock, flags); qlist_free_all(&to_free, NULL); srcu_read_unlock(&remove_cache_srcu, srcu_idx); @@ -310,17 +310,17 @@ void quarantine_remove_cache(struct kmem_cache *cache) */ on_each_cpu(per_cpu_remove_cache, cache, 1); - spin_lock_irqsave(&quarantine_lock, flags); + raw_spin_lock_irqsave(&quarantine_lock, flags); for (i = 0; i < QUARANTINE_BATCHES; i++) { if (qlist_empty(&global_quarantine[i])) continue; qlist_move_cache(&global_quarantine[i], &to_free, cache); /* Scanning whole quarantine can take a while. */ - spin_unlock_irqrestore(&quarantine_lock, flags); + raw_spin_unlock_irqrestore(&quarantine_lock, flags); cond_resched(); - spin_lock_irqsave(&quarantine_lock, flags); + raw_spin_lock_irqsave(&quarantine_lock, flags); } - spin_unlock_irqrestore(&quarantine_lock, flags); + raw_spin_unlock_irqrestore(&quarantine_lock, flags); qlist_free_all(&to_free, cache); -- 2.17.1