Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2790952lqz; Wed, 3 Apr 2024 08:42:00 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVE0GliGTlgqmO4gMeMC4eLx4kX7LnkIXXGTVL7s+dgCHSETCIq0AgULtG9m9iAZMhzRAvWT+Es7BNgqOnmhvT6T+65z3ow9pIDrfqCJQ== X-Google-Smtp-Source: AGHT+IFrj+RQXewlaws6tE3YSUW9n6j41Pvk00oIPpXQ57Ugk2sO+wt4aJVXfk0rO6HGVbayVDwW X-Received: by 2002:a17:906:2f8b:b0:a4e:146c:ff09 with SMTP id w11-20020a1709062f8b00b00a4e146cff09mr10366388eji.7.1712158920158; Wed, 03 Apr 2024 08:42:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712158920; cv=pass; d=google.com; s=arc-20160816; b=oXB5cSkPRAAHe0Qwa1fJ0OsJpTAXiGmILQeNYHI98LiPHnESQ7zDgb73cyvFTTHxzk KDsC9q+qAaYwj3Yb0XVF+NnsXZcQ955d4Q+1lWW7m72kn34rpLb0o3jJFXnoTHerEf5m bdk6bo77/gjJEXlh7hDmErycnXTOYj/dBmGE0wkxrv98zWgdog6Nh3bdOv6VvseGNwZO PnmZrpXGsFqxvhVfqnE6mi8D9m5H/+jnGZVC64+g9ona5/z6q1JEPFM8WekNKMxVlOlU 1KbWNOHtkCSsK2oD2LVtYgCvWCeULWkz4Z07VutinSF3tpKDPMgrr6w0iSbj9dP21Vnl tbrA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:organization:references :in-reply-to:message-id:subject:cc:to:from:date; bh=sU/QLunKz+6DeZIrHySXO9Ql5FsiDsKzp9Hqxe2XKMg=; fh=V5RdEl1YpOSijoY170Z1J17qpPRdAeTBR1eddyuWqsY=; b=QEFQ7NIrsozZnAVRoHPDM9xZxBtmqZQw0CB9KSMQ+nYCkYYSCobsqaGUW8BYXkpwGv AnO8v/oQWgdCPEXAM3W2UkF2CQ1PnFL1rAoLSCXhoUb7WTxWooIPVV4klyQYzk+Wmrub UEZEQWAkj35eJV3L4aQ3SCmg4gWzt12WaeXSwsPWc7cGxWkTxZbwHXmaEEGq2x9MX7Pt o7udRjVJzSMN79OK4qBUYl7IUMhk1qmRFf9EHHeS4uLhhvERwCakjnyMpNFxGKa9uj13 K5r+2dwfKOOXYs9MMSQR8VG7NkhX+zWhL08iSoAxu8EMNWj87lGTWbjEORhOMg/UZ2zs 2CiA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-130112-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gs34-20020a1709072d2200b00a4e5f9aa5d4si3953977ejc.422.2024.04.03.08.42.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 03 Apr 2024 08:42:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-130112-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=huawei.com dmarc=pass fromdomain=huawei.com); spf=pass (google.com: domain of linux-kernel+bounces-130112-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-130112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id DF4541F25C52 for ; Wed, 3 Apr 2024 15:41:59 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EC3714A4C0; Wed, 3 Apr 2024 15:41:53 +0000 (UTC) Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F2EAE433A8; Wed, 3 Apr 2024 15:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.176.79.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712158912; cv=none; b=S6t7r6qFoczLre6XtgZzfGZQhU7UlF3qOb4Q5KQ9eAza+CTS6zNl4nyIg/DtKda8WSUMCuOAlZciS8r6Z2jbc2G39NC45I1pir3LmjeB8CFLmt/1kgTx9ZBQ4QSpPmlrb1BJfJ0CBQiuc6d3dnBIhf2CHxIM1pI0QuC/EtQglh8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712158912; c=relaxed/simple; bh=uOAOUbv3JDIP5FfSjwmVya7Dhk/mOV2/ffsRhnQsD5w=; h=Date:From:To:CC:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=H3fNLSWQvvM2xSWJGyeiFxc9XOs2jg0xMBsax0ak97xkffstdHjR9f7CwLE67CwTWtpL2ePg9qhMLbh4jhH5iBFD8tnE0Nn+UyVueZL7mPz2G3NM7qJ49lgF+wvOl1c3YePq6/J2hQmyFaEleTNUhQmyNZpCi/SZkQwVEdV3vr8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=185.176.79.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=Huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.18.186.216]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4V8pqH2sdRz6D8XQ; Wed, 3 Apr 2024 23:40:27 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (unknown [7.191.163.240]) by mail.maildlp.com (Postfix) with ESMTPS id 0FBAB140B73; Wed, 3 Apr 2024 23:41:47 +0800 (CST) Received: from localhost (10.202.227.76) by lhrpeml500005.china.huawei.com (7.191.163.240) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2507.35; Wed, 3 Apr 2024 16:41:46 +0100 Date: Wed, 3 Apr 2024 16:41:45 +0100 From: Jonathan Cameron To: Ira Weiny CC: Dave Jiang , Davidlohr Bueso , Alison Schofield , Vishal Verma , Dan Williams , , , Kwangjin Ko Subject: Re: [PATCH] cxl/test: Enhance event testing Message-ID: <20240403164145.00007bcd@Huawei.com> In-Reply-To: <20240401-enhance-event-test-v1-1-6669a524ed38@intel.com> References: <20240401-enhance-event-test-v1-1-6669a524ed38@intel.com> Organization: Huawei Technologies Research and Development (UK) Ltd. X-Mailer: Claws Mail 4.1.0 (GTK 3.24.33; x86_64-w64-mingw32) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-ClientProxiedBy: lhrpeml500005.china.huawei.com (7.191.163.240) To lhrpeml500005.china.huawei.com (7.191.163.240) On Mon, 01 Apr 2024 22:31:58 -0700 Ira Weiny wrote: > An issue was found in the processing of event logs when the output > buffer length was not reset.[1] > > This bug was not caught with cxl-test for 2 reasons. First, the test > harness mbox_send command [mock_get_event()] does not set the output > size based on the amount of data returned like the hardware command > does. Second, the simplistic event log testing always returned the same > number of elements per-get command. > > Enhance the simulation of the event log mailbox to better match the bug > found with real hardware to cover potential regressions. > > NOTE: These changes will cause cxl-events.sh in ndctl to fail without > the fix from Kwangjin. However, no changes to the user space test was > required. Therefore ndctl itself will be compatible with old or new > kernels once both patches land in the new kernel. Good to state how many events are read out (22 I think) as that allows reader of this patch to see that it will cycle all the way around, so we will get the 4 to 1 reduction between two reads ensuring things work correctly when smaller number of events are returned. 1, 2, 3, 4, 1, 2, 3, 4, 1, 1 I think. > > [1] Link: https://lore.kernel.org/all/20240401091057.1044-1-kwangjin.ko@sk.com/ > > Cc: Kwangjin Ko > Signed-off-by: Ira Weiny Reviewed-by: Jonathan Cameron > --- > tools/testing/cxl/test/mem.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/tools/testing/cxl/test/mem.c b/tools/testing/cxl/test/mem.c > index 35ee41e435ab..6584443144de 100644 > --- a/tools/testing/cxl/test/mem.c > +++ b/tools/testing/cxl/test/mem.c > @@ -127,7 +127,7 @@ static struct { > #define CXL_TEST_EVENT_CNT_MAX 15 > > /* Set a number of events to return at a time for simulation. */ > -#define CXL_TEST_EVENT_CNT 3 > +#define CXL_TEST_EVENT_RET_MAX 4 > > struct mock_event_log { > u16 clear_idx; > @@ -222,6 +222,12 @@ static void mes_add_event(struct mock_event_store *mes, > log->nr_events++; > } > > +/* > + * Vary the number of events returned to simulate events occuring while the > + * logs are being read. > + */ > +static int ret_limit = 0; > + > static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd) > { > struct cxl_get_event_payload *pl; > @@ -233,14 +239,18 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd) > if (cmd->size_in != sizeof(log_type)) > return -EINVAL; > > - if (cmd->size_out < struct_size(pl, records, CXL_TEST_EVENT_CNT)) > + ret_limit = (ret_limit + 1) % CXL_TEST_EVENT_RET_MAX; > + if (!ret_limit) > + ret_limit = 1; > + > + if (cmd->size_out < struct_size(pl, records, ret_limit)) > return -EINVAL; > > log_type = *((u8 *)cmd->payload_in); > if (log_type >= CXL_EVENT_TYPE_MAX) > return -EINVAL; > > - memset(cmd->payload_out, 0, cmd->size_out); > + memset(cmd->payload_out, 0, struct_size(pl, records, 0)); > > log = event_find_log(dev, log_type); > if (!log || event_log_empty(log)) > @@ -248,7 +258,7 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd) > > pl = cmd->payload_out; > > - for (i = 0; i < CXL_TEST_EVENT_CNT && !event_log_empty(log); i++) { > + for (i = 0; i < ret_limit && !event_log_empty(log); i++) { > memcpy(&pl->records[i], event_get_current(log), > sizeof(pl->records[i])); > pl->records[i].event.generic.hdr.handle = > @@ -256,6 +266,7 @@ static int mock_get_event(struct device *dev, struct cxl_mbox_cmd *cmd) > log->cur_idx++; > } > > + cmd->size_out = struct_size(pl, records, i); > pl->record_count = cpu_to_le16(i); > if (!event_log_empty(log)) > pl->flags |= CXL_GET_EVENT_FLAG_MORE_RECORDS; > > --- > base-commit: 8d025e2092e29bfd13e56c78e22af25fac83c8ec > change-id: 20240401-enhance-event-test-cebeff5189cd > > Best regards,