xref: /spdk/test/interrupt/reap_unregistered_poller.sh (revision 0fa85da9c432ddd61acc179dea61d4b8e7517cd5)
1b1906912SLiu Xiaodong#!/usr/bin/env bash
2eb53c232Spaul luse#  SPDX-License-Identifier: BSD-3-Clause
3eb53c232Spaul luse#  Copyright (C) 2021 Intel Corporation
4eb53c232Spaul luse#  All rights reserved.
5eb53c232Spaul luse#
6b1906912SLiu Xiaodongtestdir=$(readlink -f $(dirname $0))
7b1906912SLiu Xiaodongrootdir=$(readlink -f $testdir/../..)
8b1906912SLiu Xiaodongsource $rootdir/test/common/autotest_common.sh
9b1906912SLiu Xiaodongsource $testdir/interrupt_common.sh
10b1906912SLiu Xiaodong
11*0fa85da9SJim Harris# This test script makes sure that unregistered pollers are
12*0fa85da9SJim Harris# reaped correctly when the target is running in interrupt mode.
13*0fa85da9SJim Harris
147610bc38SKonrad Sztyberexport PYTHONPATH=$PYTHONPATH:$rootdir/examples/interrupt_tgt
15b1906912SLiu Xiaodong
16b1906912SLiu Xiaodong# Set reactors with intr_tgt in intr mode
17b1906912SLiu Xiaodongstart_intr_tgt
18b1906912SLiu Xiaodong
19b1906912SLiu Xiaodong# Record names of native created pollers.
20b1906912SLiu Xiaodongapp_thread=$(rpc_cmd thread_get_pollers | jq -r '.threads[0]')
21b1906912SLiu Xiaodongnative_pollers=$(jq -r '.active_pollers[].name' <<< $app_thread)
22b1906912SLiu Xiaodongnative_pollers+=" "
23b1906912SLiu Xiaodongnative_pollers+=$(jq -r '.timed_pollers[].name' <<< $app_thread)
24b1906912SLiu Xiaodong
25b1906912SLiu Xiaodong# Create one aio_bdev.
26b1906912SLiu Xiaodong# During the creation, vbdev examine process will get bdev_aio create
27b1906912SLiu Xiaodong# pollers like bdev_aio_group_poll poller, and then unregister it.
28b1906912SLiu Xiaodongsetup_bdev_aio
29b1906912SLiu Xiaodong
30*0fa85da9SJim Harris# Wait for examine to finish, and then sleep a very short amount of
31*0fa85da9SJim Harris# time to allow the unregistered pollers to get reaped next time
32*0fa85da9SJim Harris# the spdk_threads are polled
33*0fa85da9SJim Harris"$rpc_py" bdev_wait_for_examine
34*0fa85da9SJim Harrissleep 0.1
35*0fa85da9SJim Harris
36b1906912SLiu Xiaodong# Record names of remaining pollers.
37b1906912SLiu Xiaodongapp_thread=$(rpc_cmd thread_get_pollers | jq -r '.threads[0]')
38b1906912SLiu Xiaodongremaining_pollers=$(jq -r '.active_pollers[].name' <<< $app_thread)
39b1906912SLiu Xiaodongremaining_pollers+=" "
40b1906912SLiu Xiaodongremaining_pollers+=$(jq -r '.timed_pollers[].name' <<< $app_thread)
41b1906912SLiu Xiaodong
42b1906912SLiu Xiaodong# Since bdev_aio created pollers were already unregistered, so
43b1906912SLiu Xiaodong# remaining_pollers should be same with native_pollers.
44ad672ce2SMichal Berger[[ "$remaining_pollers" == "$native_pollers" ]]
45b1906912SLiu Xiaodong
46b1906912SLiu Xiaodongtrap - SIGINT SIGTERM EXIT
47b1906912SLiu Xiaodongkillprocess $intr_tgt_pid
48b1906912SLiu Xiaodongcleanup
49