Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3296800pxk; Mon, 21 Sep 2020 09:58:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzyA/dvEOT+vPrVHNv0tS03XORzjD3Ts+ivexRM1uIc41bBP86EEA8OnYHTh0Z4VTEaKJM6 X-Received: by 2002:a17:906:4902:: with SMTP id b2mr406505ejq.208.1600707530972; Mon, 21 Sep 2020 09:58:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600707530; cv=none; d=google.com; s=arc-20160816; b=p5iQib1ZAZKwTBvo1ZWDokxOfIBxDlZPClMz6Fn4JEha6RvqcQ9OUPDRT+eONe+Lyl JTSQcEwBusL53YG43qdTdP31hSbaOvFvZwzu2CMr5Px26AXOrGfvdcUvhGq9wXV67TzS Bs7eCNy2BRK7coQuiwKsKij7IcgiCK0zq0ZjOxkPqnIikmkoraAucKQcNohIVke7KSOo XvO9CLvsBjUcq21KXBtVRbSpysiETn5j9zETLapra11RCgFEFFHQ5YMPPwEUYRP1Eas7 fTKwQLwSMMYhGqNkrqEXE8m0GI9nGAw91V0WjzbiDia27RV1sR+Ql2H42bur4IZCCaG+ QKjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YlEcrWskvh2KrODmTVxDDWI7Jj5LyhVLo8f5FBaFq5k=; b=nEfh6iQyhkMRsAedn1SLYLLp8IAJtTiGby2Hh5r8Xb2xCzwie8QrdowADo33a8mlSP pVgY71edp0Y1McK9W/bkvpxgeTzNiVG1DXxXo7VxEYLKcSxkfZwsfA4u4mjRJYrRjIKb ZgE5OFzKVCEsXGGEiUeyyg7V8k0w0mKtc7A4n4kWe5lloJF1wJpTqOWtV+1pCMAHQTQk KNAdxBO+JBBN0JWSFBVSuWhtvfN9wzOveKRfjW7rl3JpovMLbMg7xa3AWZPjgknQ0gWq TL4dKTOLxO7NmlHasuzasH8j+AS6hHdzRiJepY0NzY2FIQSDWtWz9wQ5nT7Ie+Fkstfe 0oHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=N1dCtdFL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qn24si8445708ejb.299.2020.09.21.09.58.27; Mon, 21 Sep 2020 09:58:50 -0700 (PDT) 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=@kernel.org header.s=default header.b=N1dCtdFL; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729747AbgIUQ40 (ORCPT + 99 others); Mon, 21 Sep 2020 12:56:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:50722 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729711AbgIUQpC (ORCPT ); Mon, 21 Sep 2020 12:45:02 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 01A242076B; Mon, 21 Sep 2020 16:45:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600706701; bh=jyDJds9Pn2QLe5k6ZDtSQyStUbTcJpabXAVatAV8e9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N1dCtdFL0xA6qLy4JIuJmJltmUajDFTCt4eLZFBWEz8tCrP640hpZAVb8SKLvSbS9 ENTIZhwP3R3o3dHdPxXmNC46K2PShJqg81/XBvuw4Uu3Bx9P2xGGupyzwOdbE9DMeE DmI7qn7qB38rXuzkPjdXNUWOALSrXtC1lUW3wJDg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Yang Yang , Omar Sandoval , Jens Axboe , Sasha Levin Subject: [PATCH 5.8 029/118] block: only call sched requeue_request() for scheduled requests Date: Mon, 21 Sep 2020 18:27:21 +0200 Message-Id: <20200921162037.675154963@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200921162036.324813383@linuxfoundation.org> References: <20200921162036.324813383@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Omar Sandoval [ Upstream commit e8a8a185051a460e3eb0617dca33f996f4e31516 ] Yang Yang reported the following crash caused by requeueing a flush request in Kyber: [ 2.517297] Unable to handle kernel paging request at virtual address ffffffd8071c0b00 ... [ 2.517468] pc : clear_bit+0x18/0x2c [ 2.517502] lr : sbitmap_queue_clear+0x40/0x228 [ 2.517503] sp : ffffff800832bc60 pstate : 00c00145 ... [ 2.517599] Process ksoftirqd/5 (pid: 51, stack limit = 0xffffff8008328000) [ 2.517602] Call trace: [ 2.517606] clear_bit+0x18/0x2c [ 2.517619] kyber_finish_request+0x74/0x80 [ 2.517627] blk_mq_requeue_request+0x3c/0xc0 [ 2.517637] __scsi_queue_insert+0x11c/0x148 [ 2.517640] scsi_softirq_done+0x114/0x130 [ 2.517643] blk_done_softirq+0x7c/0xb0 [ 2.517651] __do_softirq+0x208/0x3bc [ 2.517657] run_ksoftirqd+0x34/0x60 [ 2.517663] smpboot_thread_fn+0x1c4/0x2c0 [ 2.517667] kthread+0x110/0x120 [ 2.517669] ret_from_fork+0x10/0x18 This happens because Kyber doesn't track flush requests, so kyber_finish_request() reads a garbage domain token. Only call the scheduler's requeue_request() hook if RQF_ELVPRIV is set (like we do for the finish_request() hook in blk_mq_free_request()). Now that we're handling it in blk-mq, also remove the check from BFQ. Reported-by: Yang Yang Signed-off-by: Omar Sandoval Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- block/bfq-iosched.c | 12 ------------ block/blk-mq-sched.h | 2 +- 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c index 50c8f034c01c5..caa4fa7f42b84 100644 --- a/block/bfq-iosched.c +++ b/block/bfq-iosched.c @@ -5895,18 +5895,6 @@ static void bfq_finish_requeue_request(struct request *rq) struct bfq_queue *bfqq = RQ_BFQQ(rq); struct bfq_data *bfqd; - /* - * Requeue and finish hooks are invoked in blk-mq without - * checking whether the involved request is actually still - * referenced in the scheduler. To handle this fact, the - * following two checks make this function exit in case of - * spurious invocations, for which there is nothing to do. - * - * First, check whether rq has nothing to do with an elevator. - */ - if (unlikely(!(rq->rq_flags & RQF_ELVPRIV))) - return; - /* * rq either is not associated with any icq, or is an already * requeued request that has not (yet) been re-inserted into diff --git a/block/blk-mq-sched.h b/block/blk-mq-sched.h index 126021fc3a11f..e81ca1bf6e10b 100644 --- a/block/blk-mq-sched.h +++ b/block/blk-mq-sched.h @@ -66,7 +66,7 @@ static inline void blk_mq_sched_requeue_request(struct request *rq) struct request_queue *q = rq->q; struct elevator_queue *e = q->elevator; - if (e && e->type->ops.requeue_request) + if ((rq->rq_flags & RQF_ELVPRIV) && e && e->type->ops.requeue_request) e->type->ops.requeue_request(rq); } -- 2.25.1