Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp844413rwb; Wed, 16 Nov 2022 08:22:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf4lbUmygbgfgL8DtctKjnTi5O6KnCvikzWLQCYvT1WKD6uZPzlC04D3wA6OaZgsMNJBUxuq X-Received: by 2002:a17:906:ca4f:b0:7ae:5a4:5356 with SMTP id jx15-20020a170906ca4f00b007ae05a45356mr18683664ejb.748.1668615721076; Wed, 16 Nov 2022 08:22:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668615721; cv=none; d=google.com; s=arc-20160816; b=r62RnYrVj9/Fu7Flx60SvA/aQ5h4+IDS4aWue+jIC+n4/kaLz9sGWnlbA9OJ7xO98T lAuCbClwLiEIEwEp3qBpCFN1QY+hip9S43uL2USRilbS8UcU+gvcwncb9XHPM+/Ph0ur VcuqK0FzpDy80HhZJJcbHYYbyraPdVGrOSo4ftDVAZUcUa79BCYwFQy+EVjaZm4N94nx 4j5dCCKj0k/BWBCcHHzbwO7oNcV1BGsRb6A2PEYJzPoHCkabHKMGLkknebctAAsTT8ya qRlwO97t6pbSQlpFesSp9q925JYF965Oe5V59452c2JhxWdTFWN/J9pQ4j3i3s/OxIMO +D2w== 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 :organization:references:in-reply-to:message-id:subject:cc:to:from :date; bh=LU65UUkf2DnWGivo2YnMVeYhkoeMHhoj9NLrPr0Oenk=; b=mxHifGaoGmvCvEhDhD+t/ex2WONgSkJRxmema32KIiaJ1yUkMeLyZPNX+vKYya+zyk pUUt2dWtypyK25e1yDkli1iBPF9DnzxSfJFG2DFAXzHTz8NVMaxKCYnZqG5j8YX39ivN 5JfF302tPnEK6T3b12p41XMfttVWB1nN1sxJTrEYm+JK316cPiYOkKRJPtOGd6KE3JNF nNp3wLnf/ehIdT01DywzzQfUbCtAqrtFC2JMx/Sjsn2qtgfbR463JG2vn4SWh1xURVNv kYcfNTBOr9bL66lKEGQAYe1VvEIUnXM9OPMmyGgKpondHXzbuseWuqjqmIOK0750aHII j5ag== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a1709063e0400b0078d4ba46622si12490812eji.616.2022.11.16.08.21.38; Wed, 16 Nov 2022 08:22:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230459AbiKPQKX (ORCPT + 91 others); Wed, 16 Nov 2022 11:10:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233839AbiKPQKM (ORCPT ); Wed, 16 Nov 2022 11:10:12 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D5E14C279; Wed, 16 Nov 2022 08:10:11 -0800 (PST) Received: from fraeml707-chm.china.huawei.com (unknown [172.18.147.200]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NC7Dn50JNz687hk; Thu, 17 Nov 2022 00:05:29 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml707-chm.china.huawei.com (10.206.15.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 17:10:09 +0100 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_128_GCM_SHA256) id 15.1.2375.31; Wed, 16 Nov 2022 16:10:08 +0000 Date: Wed, 16 Nov 2022 16:10:08 +0000 From: Jonathan Cameron To: CC: Dan Williams , Alison Schofield , Vishal Verma , "Ben Widawsky" , Steven Rostedt , Davidlohr Bueso , , Subject: Re: [PATCH 11/11] cxl/test: Simulate event log overflow Message-ID: <20221116161008.00004f71@Huawei.com> In-Reply-To: <20221110185758.879472-12-ira.weiny@intel.com> References: <20221110185758.879472-1-ira.weiny@intel.com> <20221110185758.879472-12-ira.weiny@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) MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.202.227.76] X-ClientProxiedBy: lhrpeml500002.china.huawei.com (7.191.160.78) To lhrpeml500005.china.huawei.com (7.191.163.240) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Nov 2022 10:57:58 -0800 ira.weiny@intel.com wrote: > From: Ira Weiny > > Log overflow is marked by a separate trace message. > > Simulate a log with lots of messages and flag overflow until it is > drained a bit. > > Signed-off-by: Ira Weiny Looks fine to me Reviewed-by: Jonathan Cameron > > --- > Changes from RFC > Adjust for new struct changes > --- > tools/testing/cxl/test/events.c | 37 +++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/tools/testing/cxl/test/events.c b/tools/testing/cxl/test/events.c > index 8693f3fb9cbb..5ce257114f4e 100644 > --- a/tools/testing/cxl/test/events.c > +++ b/tools/testing/cxl/test/events.c > @@ -69,11 +69,21 @@ static void event_store_add_event(struct mock_event_store *mes, > log->nr_events++; > } > > +static u16 log_overflow(struct mock_event_log *log) > +{ > + int cnt = log_rec_left(log) - 5; > + > + if (cnt < 0) > + return 0; > + return cnt; > +} > + > int mock_get_event(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) > { > struct cxl_get_event_payload *pl; > struct mock_event_log *log; > u8 log_type; > + u16 nr_overflow; > > /* Valid request? */ > if (cmd->size_in != sizeof(log_type)) > @@ -95,6 +105,20 @@ int mock_get_event(struct cxl_dev_state *cxlds, struct cxl_mbox_cmd *cmd) > if (log_rec_left(log) > 1) > pl->flags |= CXL_GET_EVENT_FLAG_MORE_RECORDS; > > + nr_overflow = log_overflow(log); > + if (nr_overflow) { > + u64 ns; > + > + pl->flags |= CXL_GET_EVENT_FLAG_OVERFLOW; > + pl->overflow_err_count = cpu_to_le16(nr_overflow); > + ns = ktime_get_real_ns(); > + ns -= 5000000000; /* 5s ago */ > + pl->first_overflow_timestamp = cpu_to_le64(ns); > + ns = ktime_get_real_ns(); > + ns -= 1000000000; /* 1s ago */ > + pl->last_overflow_timestamp = cpu_to_le64(ns); > + } > + > memcpy(&pl->record[0], get_cur_event(log), sizeof(pl->record[0])); > pl->record[0].hdr.handle = get_cur_event_handle(log); > return 0; > @@ -274,6 +298,19 @@ u32 cxl_mock_add_event_logs(struct cxl_dev_state *cxlds) > (struct cxl_event_record_raw *)&mem_module); > mes->ev_status |= CXLDEV_EVENT_STATUS_INFO; > > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, &maint_needed); > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, &hardware_replace); > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, > + (struct cxl_event_record_raw *)&dram); > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, > + (struct cxl_event_record_raw *)&gen_media); > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, > + (struct cxl_event_record_raw *)&mem_module); > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, &hardware_replace); > + event_store_add_event(mes, CXL_EVENT_TYPE_FAIL, > + (struct cxl_event_record_raw *)&dram); > + mes->ev_status |= CXLDEV_EVENT_STATUS_FAIL; > + > event_store_add_event(mes, CXL_EVENT_TYPE_FATAL, &hardware_replace); > event_store_add_event(mes, CXL_EVENT_TYPE_FATAL, > (struct cxl_event_record_raw *)&dram);