On Mon, Jun 08, 2026 at 05:24:08PM -0700, Dave Jiang wrote:
> 
> 
> On 5/23/26 2:50 AM, Anisa Su wrote:
> > From: Ira Weiny <[email protected]>
> > 
> > cxl_test provides a good way to ensure quick smoke and regression
> > testing.  The complexity of DCD and the new sparse DAX regions
> > required to use them benefits greatly with a series of smoke tests.
> > 
> > The only part of the kernel stack which must be bypassed is the actual
> > irq of DCD events.  However, the event processing itself can be tested
> > via cxl_test calling directly into the event processing.
> > 
> > In this way the rest of the stack; management of sparse regions, the
> > extent device lifetimes, and the dax device operations can be tested.
> > 
> > Add Dynamic Capacity Device tests for kernels which have DCD support.
> > 
> > Signed-off-by: Ira Weiny <[email protected]>
> > Signed-off-by: Anisa Su <[email protected]>
> 
> A nit below. Otherwise
> 
> Reviewed-by: Dave Jiang <[email protected]>
> 
[snip] 
> > +test_event_reporting()
> > +{
> > +   # Test event reporting
> > +   # results expected
> > +   num_dcd_events_expected=2
> > +
> > +   echo "Test: Prep event trace"
> > +   echo "" > /sys/kernel/tracing/trace
> > +   echo 1 > /sys/kernel/tracing/events/cxl/enable
> > +   echo 1 > /sys/kernel/tracing/tracing_on
> > +
> > +   inject_extent ${device} $base_ext_dpa $base_ext_length ""
> > +   remove_extent ${device} $base_ext_dpa $base_ext_length
> 
> Missing the tag arg
> 
> DJ

Fixed, thanks!

Anisa
> 
> > +
> > +   echo 0 > /sys/kernel/tracing/tracing_on
> > +
> > +   echo "Test: Events seen"
> > +   trace_out=$(cat /sys/kernel/tracing/trace)
> > +
> > +   # Look for DCD events
> > +   num_dcd_events=$(grep -c "cxl_dynamic_capacity" <<< "${trace_out}")
> > +   echo "     LOG     (Expected) : (Found)"
> > +   echo "     DCD events    ($num_dcd_events_expected) : $num_dcd_events"
> > +
> > +   if [ "$num_dcd_events" -ne $num_dcd_events_expected ]; then
> > +           err "$LINENO"
> > +   fi
> > +}
> > +
> > +
> > +# ========================================================================
> > +# main()
> > +# ========================================================================
> > +
> > +modprobe -r cxl_test
> > +modprobe cxl_test
> > +
> > +# The mock stamps a single cxl_mem instance with this serial (0xDCDC).
> > +# That memdev's DC partition is advertised as sharable in CDAT and is
> > +# the only one that can host the shared-extent tests.  All other DCD
> > +# memdevs stay non-sharable and host the rest of the suite.
> > +MOCK_DC_SHARABLE_SERIAL=56540
> > +
> > +readarray -t memdevs < <("$CXL" list -b cxl_test -Mi | jq -r '.[].memdev')
> > +
> > +sharable_mem=""
> > +sharable_decoder=""
> > +sharable_bus=""
> > +sharable_device=""
> > +sharable_dra_size=""
> > +
> > +for cand in ${memdevs[@]}; do
> > +   cand_dra=$($CXL list -m $cand | jq -r '.[].dynamic_ram_a_size')
> > +   if [ "$cand_dra" == "null" ]; then
> > +           continue
> > +   fi
> > +   cand_decoder=$($CXL list -b cxl_test -D -d root -m "$cand" |
> > +             jq -r ".[] |
> > +             select(.volatile_capable == true) |
> > +             select(.nr_targets == 1) |
> > +             select(.max_available_extent >= ${cand_dra}) |
> > +             .decoder")
> > +   if [[ -z "$cand_decoder" ]]; then
> > +           continue
> > +   fi
> > +   cand_serial=$($CXL list -m $cand | jq -r '.[].serial')
> > +   cand_bus=`"$CXL" list -b cxl_test -m ${cand} | jq -r '.[].bus'`
> > +   cand_device=$($CXL list -m $cand | jq -r '.[].host')
> > +
> > +   if [ "$cand_serial" == "$MOCK_DC_SHARABLE_SERIAL" ]; then
> > +           if [ -z "$sharable_mem" ]; then
> > +                   sharable_mem="$cand"
> > +                   sharable_decoder="$cand_decoder"
> > +                   sharable_bus="$cand_bus"
> > +                   sharable_device="$cand_device"
> > +                   sharable_dra_size="$cand_dra"
> > +           fi
> > +   else
> > +           if [ -z "$mem" ]; then
> > +                   mem="$cand"
> > +                   decoder="$cand_decoder"
> > +                   bus="$cand_bus"
> > +                   device="$cand_device"
> > +                   dra_size="$cand_dra"
> > +           fi
> > +   fi
> > +
> > +   if [ -n "$mem" ] && [ -n "$sharable_mem" ]; then
> > +           break
> > +   fi
> > +done
> > +
> > +echo "TEST: non-sharable bus:${bus} decoder:${decoder} mem:${mem} 
> > device:${device} size:${dra_size}"
> > +echo "TEST: sharable     bus:${sharable_bus} decoder:${sharable_decoder} 
> > mem:${sharable_mem} device:${sharable_device} size:${sharable_dra_size}"
> > +
> > +if [ "$decoder" == "" ] || [ "$device" == "" ] || [ "$dra_size" == "" ]; 
> > then
> > +   echo "No non-sharable mem device/decoder found with DCD support"
> > +   exit 77
> > +fi
> > +
> > +if [ "$sharable_mem" == "" ]; then
> > +   echo "No sharable mem device found (mock did not stamp 
> > MOCK_DC_SHARABLE_SERIAL)"
> > +   exit 77
> > +fi
> > +
> > +# testing pre existing extents must be called first as the extents were 
> > created
> > +# by cxl-test being loaded
> > +test_pre_existing_extents
> > +test_remove_extent_under_dax_device
> > +test_create_dax_dev_spanning_two_extents
> > +test_inject_tag_support
> > +test_uuid_no_match
> > +test_uuid_no_match_seed_intact
> > +test_uuid_aggregation
> > +test_uuid_show
> > +# These two run on the sharable memdev (serial $MOCK_DC_SHARABLE_SERIAL).
> > +test_shared_extent_inject
> > +test_seq_integrity_gap
> > +test_cross_more_uniqueness
> > +test_alignment_rejection
> > +test_partial_extent_remove
> > +test_multiple_extent_remove
> > +test_destroy_region_without_extent_removal
> > +test_destroy_with_extent_and_dax
> > +test_dax_device_ops
> > +test_reject_overlapping
> > +test_two_regions
> > +test_more_bit
> > +test_driver_reload
> > +test_event_reporting
> > +
> > +modprobe -r cxl_test
> > +
> > +check_dmesg "$LINENO"
> > +
> > +exit 0
> > diff --git a/test/meson.build b/test/meson.build
> > index e0e2193..cd06bf8 100644
> > --- a/test/meson.build
> > +++ b/test/meson.build
> > @@ -171,6 +171,7 @@ cxl_translate = find_program('cxl-translate.sh')
> >  cxl_elc = find_program('cxl-elc.sh')
> >  cxl_dax_hmem = find_program('cxl-dax-hmem.sh')
> >  cxl_region_replay = find_program('cxl-region-replay.sh')
> > +cxl_dcd = find_program('cxl-dcd.sh')
> >  
> >  tests = [
> >    [ 'libndctl',               libndctl,              'ndctl' ],
> > @@ -207,6 +208,7 @@ tests = [
> >    [ 'cxl-elc.sh',             cxl_elc,            'cxl'   ],
> >    [ 'cxl-dax-hmem.sh',        cxl_dax_hmem,       'cxl'   ],
> >    [ 'cxl-region-replay.sh',   cxl_region_replay,  'cxl'   ],
> > +  [ 'cxl-dcd.sh',             cxl_dcd,            'cxl'   ],
> >  ]
> >  
> >  if get_option('destructive').enabled()
> 

Reply via email to