From patchwork Wed Dec 12 23:09:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 10727375 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C5E413BF for ; Wed, 12 Dec 2018 23:10:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3DFB42B445 for ; Wed, 12 Dec 2018 23:10:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 320FD2B4A6; Wed, 12 Dec 2018 23:10:07 +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,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 2561C2B445 for ; Wed, 12 Dec 2018 23:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726214AbeLLXKE (ORCPT ); Wed, 12 Dec 2018 18:10:04 -0500 Received: from mail-yw1-f48.google.com ([209.85.161.48]:42980 "EHLO mail-yw1-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726253AbeLLXKE (ORCPT ); Wed, 12 Dec 2018 18:10:04 -0500 Received: by mail-yw1-f48.google.com with SMTP id x2so47267ywc.9 for ; Wed, 12 Dec 2018 15:10:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bTvLJoxvowriT86ggcJOB2/6d3/zjRLTJV+ZHwfKSUI=; b=ElAKo2LfDBwiDKAuEFAz2K/6hK6xcxJLn5UjVEmEVTanraI1HrBbrSdPEsGvcxwbzR ccwDuViviMcxflfMw3/LeSofW1ZQaLw/OfsDfRF2MyvW0Ubd0PuCZAjVVP9DG10Sy7Az rcHk4eYDANjZEKSbNfBBG10Apbb+Gj/j6bJVONKUi/JPEXCE+BzzqcmhTZOdYAhY/C5J G6IEgJIh8tZYtWS65C5lzJ1poBeh/cNngtMFVdxBHVNjXqRQbs8h8L4JMzUJtChCb3Kr ZcN2aPtW3MiJj7SZwpo6kD3U8Xi1hJVVSUfFh+XKOEZpum31m4IQHx+41CCvMFpBocwa lXOw== X-Gm-Message-State: AA+aEWa0NQqIaNi43m/3seM/qH5qh4WPKb220IIbLtUeB5DjwXhMEGFB ug/8Tj2cqP+z3XZa6R/fbX8= X-Google-Smtp-Source: AFSGD/XRdlwifncuY0NJ2Wtv5lkUFUwB+jOyRMUgLzPLlJSHQfUt4LmswcIPAK15RN4iLY5iKTjSVw== X-Received: by 2002:a81:2714:: with SMTP id n20mr22603385ywn.77.1544656202559; Wed, 12 Dec 2018 15:10:02 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.135]) by smtp.gmail.com with ESMTPSA id i21sm137832ywg.5.2018.12.12.15.10.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Dec 2018 15:10:01 -0800 (PST) From: Dennis Zhou To: Omar Sandoval , Ming Lei Cc: kernel-team@fb.com, linux-block@vger.kernel.org, Dennis Zhou Subject: [PATCH blktests 1/2] blktests: split out cgroup2 controller and file check Date: Wed, 12 Dec 2018 18:09:58 -0500 Message-Id: <20181212230959.69975-2-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181212230959.69975-1-dennis@kernel.org> References: <20181212230959.69975-1-dennis@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This is a prep patch for a new test that will race blkg association and request_queue cleanup. As blkg association is a underlying cgroup io controller feature, we need the ability to check if the controller is available. Signed-off-by: Dennis Zhou --- common/cgroup | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/common/cgroup b/common/cgroup index d445093..3481458 100644 --- a/common/cgroup +++ b/common/cgroup @@ -37,19 +37,27 @@ _have_cgroup2() return 0 } -_have_cgroup2_controller_file() +_have_cgroup2_controller() { - _have_cgroup2 || return 1 - local controller="$1" - local file="$2" - local dir + + _have_cgroup2 || return 1 dir="$(_cgroup2_base_dir)" + if ! grep -q "$controller" "$dir/cgroup.controllers"; then SKIP_REASON="no support for $controller cgroup controller; if it is enabled, you may need to boot with cgroup_no_v1=$controller" return 1 fi +} + +_have_cgroup2_controller_file() +{ + local controller="$1" + local file="$2" + local dir + + _have_cgroup_2_controller "$controller" || return 1 mkdir "$dir/blktests" echo "+$controller" > "$dir/cgroup.subtree_control" From patchwork Wed Dec 12 23:09:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dennis Zhou X-Patchwork-Id: 10727377 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D31993E9D for ; Wed, 12 Dec 2018 23:10:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C40A02B46F for ; Wed, 12 Dec 2018 23:10:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B80DE2B72E; Wed, 12 Dec 2018 23:10:07 +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,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 A15C32B46F for ; Wed, 12 Dec 2018 23:10:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726253AbeLLXKF (ORCPT ); Wed, 12 Dec 2018 18:10:05 -0500 Received: from mail-yw1-f66.google.com ([209.85.161.66]:37340 "EHLO mail-yw1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728121AbeLLXKE (ORCPT ); Wed, 12 Dec 2018 18:10:04 -0500 Received: by mail-yw1-f66.google.com with SMTP id h193so58647ywc.4 for ; Wed, 12 Dec 2018 15:10:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gehLJkuzE2X6rIJfz23DkpRIt/ansKL7Mvm45OYkhik=; b=QTl1aGTxQL/2UAGnfzoHrafjFNcSyJtwHeld4CPji7psRoau7+Flqu4mHs3Dj6P3yH 4R4xMzvyHqUd11A9ECWBMMwlE2Q9fUEhhySnsapb3s2Pd3lL1SKCKE4JflAeB7xggb/V 4MTStiHSFIedlREiAIjoeGMBvCasOSTNxJ9xXKpZg2weHQPLUkNudm92qS8AJL2XBJdY KOpOckxqzr0kaI6Cuqre+vIckzZqhKFIqR0cypF5Zo7zeNeF5uXLuYEoh7T+9p+melT3 jtx4EA/6WO76v5pgwM2ud1vKnWilSIVpM/Cz/A42W+StAaVexrH1KyMJkbNzw9oBZM4j wpkA== X-Gm-Message-State: AA+aEWb7bMrHSAre0mTMiUYvjehlJZNF9Bu5pkFiFpUsY61r+/m39ODp c2WUQRwJ3WriRf5k5GmOM+k= X-Google-Smtp-Source: AFSGD/WxFpF0gtkYRP7hlIXOYJkqxhyNOknyg1AQ1bMci2PVgujAUTysPxrWEzUfOar1PO5hS772nQ== X-Received: by 2002:a0d:d305:: with SMTP id v5mr23667087ywd.109.1544656203660; Wed, 12 Dec 2018 15:10:03 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.135]) by smtp.gmail.com with ESMTPSA id i21sm137832ywg.5.2018.12.12.15.10.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 12 Dec 2018 15:10:02 -0800 (PST) From: Dennis Zhou To: Omar Sandoval , Ming Lei Cc: kernel-team@fb.com, linux-block@vger.kernel.org, Dennis Zhou Subject: [PATCH blktests 2/2] blktests: add Ming Lei's scsi-stress-remove Date: Wed, 12 Dec 2018 18:09:59 -0500 Message-Id: <20181212230959.69975-3-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20181212230959.69975-1-dennis@kernel.org> References: <20181212230959.69975-1-dennis@kernel.org> Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This test exposed a race condition with shutting down a request_queue and the new blkg association. The issue ended up being that while the request_queue will just start failing requests, blkg destruction sets the q->root_blkg to %NULL. This caused a NPE when trying to reference it. So to help prevent this from happening again, integrate Ming's test into blktests so that it can more easily be ran. Signed-off-by: Dennis Zhou Cc: Ming Lei --- tests/block/022 | 96 +++++++++++++++++++++++++++++++++++++++++++++ tests/block/022.out | 2 + 2 files changed, 98 insertions(+) create mode 100755 tests/block/022 create mode 100644 tests/block/022.out diff --git a/tests/block/022 b/tests/block/022 new file mode 100755 index 0000000..45bfff7 --- /dev/null +++ b/tests/block/022 @@ -0,0 +1,96 @@ +#!/bin/bash +# SPDX-License-Identifier: GPL-3.0+ +# Copyright (C) 2018 Ming Lei +# +# Regression test for patch "blkcg: handle dying request_queue when associating +# a blkg" +# +# This tries to expose the race condition between blkg association and +# request_queue shutdown. When a request_queue is shutdown, the corresponding +# blkgs are destroyed. Any further associations should fail gracefully and not +# cause a kernel panic. + +. tests/block/rc +. common/scsi_debug +. common/cgroup + +DESCRIPTION="test graceful shutdown of scsi_debug devices with running fio jobs" +QUICK=1 + +requires() { + _have_cgroup2_controller io && _have_scsi_debug && _have_fio +} + +scsi_debug_stress_remove() { + scsi_debug_path="/sys/bus/pseudo/drivers/scsi_debug" + count=21 + + runtime=12 + nr_fio_jobs=8 + scsi_dbg_ndelay=10000 + + # set higher aio limit + echo 524288 > /proc/sys/fs/aio-max-nr + + #figure out the CAN_QUEUE + can_queue=$(((count + 1) * (count / 2) / 2)) + + rmmod scsi_debug > /dev/null 2>&1 + modprobe scsi_debug virtual_gb=128 max_luns=$count \ + ndelay=$scsi_dbg_ndelay max_queue=$can_queue + + # figure out scsi_debug disks + hosts=$(ls -d /sys/bus/pseudo/drivers/scsi_debug/adapter0/host*) + hostname=$(basename "$hosts") + host=$(echo "$hostname" | grep -o -E '[0-9]+') + + sdisks=$(ls -d $scsi_debug_path/adapter*/"$hostname"/target*/*/block/*) + disks="" + for sd in $sdisks; do + disks+="/dev/"$(basename "$sd") + disks+=" " + done + + use_mq=$(cat /sys/module/scsi_mod/parameters/use_blk_mq) + if [[ $use_mq = "Y" ]]; then + scheds=("none" "mq-deadline" "kyber") + else + scheds=("noop" "deadline" "cfq") + fi + + fio_jobs="" + cnt=0 + for sd in $disks; do + cnt=$((cnt+1)) + fio_jobs=$fio_jobs" --name=job1 --filename=$sd: " + dev_name=$(basename "$sd") + q_path=/sys/block/$dev_name/queue + + sched_idx=$((cnt % ${#scheds[@]})) + echo "${scheds[$sched_idx]}" > "$q_path/scheduler" + echo $cnt > "$q_path/../device/queue_depth" + done + + fio --rw=randread --size=128G --direct=1 --ioengine=libaio \ + --iodepth=2048 --numjobs=$nr_fio_jobs --bs=4k \ + --group_reporting=1 --group_reporting=1 --runtime=$runtime \ + --loops=10000 "$fio_jobs" > "$FULL" 2>&1 & + + sleep 7 + for sd in $disks; do + dev_name=$(basename "$sd") + dpath=/sys/block/$dev_name/device + [ -f "$dpath/delete" ] && echo 1 > "$dpath/delete" + done + + wait +} + + +test() { + echo "Running ${TEST_NAME}" + + scsi_debug_stress_remove + + echo "Test complete" +} diff --git a/tests/block/022.out b/tests/block/022.out new file mode 100644 index 0000000..14d43cb --- /dev/null +++ b/tests/block/022.out @@ -0,0 +1,2 @@ +Running block/022 +Test complete