Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2089961rwb; Fri, 2 Dec 2022 05:28:54 -0800 (PST) X-Google-Smtp-Source: AA0mqf6yWJOV2KT3PMHDtSjccmZQVJRfAA1QP9fZ0gpkheQmJDQz5O+bUIbuyj2JAojsMddfGtqz X-Received: by 2002:a63:dd41:0:b0:478:645f:c2fb with SMTP id g1-20020a63dd41000000b00478645fc2fbmr10155227pgj.239.1669987734312; Fri, 02 Dec 2022 05:28:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669987734; cv=none; d=google.com; s=arc-20160816; b=Ey/B0/bRYQFdv55AohfcMK09MiG9GF+PrNSdoI4R/1bad22iFZ5Tu+HjvT/fd7tLZm E0QmD/dRJ6OaQmtvivTFy6hlquhxwWT2Rm80IOxe9pfKrynq/Usu8dOYpERvQ7P/eSkx oAmwcNiQgQuxZL2KUZxp3wpiAjA5boBkSpfoFMwD8rwQXslczSqFN6zkWWDwv8X4hFdF GRSlJo/Mr+I+4HrAMyPQFHH6uOhgHRRJZxVD9tTznH1oeKKwkRKDlXdMbCFI33a0UPQl VncCJ8FgGbFbBicyeVyy382a+OSqyBh5DACk8EgAaY7FkuCknC+bXOD2yqNkK8tzL/up NYfQ== 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=8N3WluLiqkwUf0EeCM/jYn0o3YmcAyiVVF8WzYgSrG0=; b=KgwvYl1EAhJOf/Rzn9bzZryFKNaCRIP3IeV5IJM0Jw4KZYBDTUHVvLGJ26aQPN0n60 S8EwZoA3tsS4OnTuiP88K4+wsylg7Zlcdriyc4TDybqssH9TkOI2H0ciTNqCV9RRwQHK SBWDSwIKdZCCaHTQWN/Z6L33uVAKeuB2d8IwSYAdradwR8pQP1WbsngJx6X+DCU2zAmE jrlxehAL3LoC/RdDBQvBK9v02BflisNXu/n+7ceI3AJwPUugfi9M4SlqxG7MVVv6zaHh 7zfKGcKCMobUj7TteBYv5+ObAMSAGLxDuT5ooZzgu+pptnsooHOda+e6HNWqfmW2uPCj LtEg== 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 pj2-20020a17090b4f4200b0021406fde039si7461874pjb.156.2022.12.02.05.28.41; Fri, 02 Dec 2022 05:28:54 -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 S233491AbiLBNSy (ORCPT + 83 others); Fri, 2 Dec 2022 08:18:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232705AbiLBNSq (ORCPT ); Fri, 2 Dec 2022 08:18:46 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CFC55A1C3A; Fri, 2 Dec 2022 05:18:42 -0800 (PST) Received: from fraeml702-chm.china.huawei.com (unknown [172.18.147.201]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NNtmL5LLfz6J68q; Fri, 2 Dec 2022 21:18:10 +0800 (CST) Received: from lhrpeml500005.china.huawei.com (7.191.163.240) by fraeml702-chm.china.huawei.com (10.206.15.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2375.31; Fri, 2 Dec 2022 14:18:40 +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.34; Fri, 2 Dec 2022 13:18:40 +0000 Date: Fri, 2 Dec 2022 13:18:36 +0000 From: Jonathan Cameron To: Dan Williams CC: , Alison Schofield , Vishal Verma , Ben Widawsky , Steven Rostedt , Davidlohr Bueso , Dave Jiang , , Subject: Re: [PATCH V2 03/11] cxl/mem: Implement Clear Event Records command Message-ID: <20221202131836.00000f35@Huawei.com> In-Reply-To: <6389630036769_3cbe02947d@dwillia2-xfh.jf.intel.com.notmuch> References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-4-ira.weiny@intel.com> <6389630036769_3cbe02947d@dwillia2-xfh.jf.intel.com.notmuch> 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: lhrpeml500001.china.huawei.com (7.191.163.213) 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 > > +static int cxl_clear_event_record(struct cxl_dev_state *cxlds, > > + enum cxl_event_log_type log, > > + struct cxl_get_event_payload *get_pl, > > + u16 total) > > +{ > > + struct cxl_mbox_clear_event_payload payload = { > > + .event_log = log, > > + }; > > + int cnt; > > + > > + /* > > + * Clear Event Records uses u8 for the handle cnt while Get Event > > + * Record can return up to 0xffff records. > > + */ > > + for (cnt = 0; cnt < total; /* cnt incremented internally */) { > > + u8 nr_recs = min_t(u8, (total - cnt), > > + CXL_CLEAR_EVENT_MAX_HANDLES); > > This seems overly complicated. @total is a duplicate of > @get_pl->record_count, and the 2 loops feel like it could be cut > down to one. You could do something nasty like for (i = 0; i < total; i++) { ... payload.handle[i % CLEAR_EVENT_MAX_HANDLES] = ... if (i % CXL_CLEAR_EVENT_MAX_HANDLES == CXL_CLEAR_EVENT_MAX_HANDLE - 1) { send command. } } but that looks worse to me than the double loop. Making outer loop for (j = 0; j <= total / CXL_CLEAR_EVENT_MAX_HANDLES; j++) might bet clearer but then you'd have to do records[j * CXL_CLEAR_EVENT_MAX_HANDLES + i] which isn't nice. Ah well, Ira gets to try and find a happy compromise. ... > > diff --git a/include/uapi/linux/cxl_mem.h b/include/uapi/linux/cxl_mem.h > > index 70459be5bdd4..7c1ad8062792 100644 > > --- a/include/uapi/linux/cxl_mem.h > > +++ b/include/uapi/linux/cxl_mem.h > > @@ -25,6 +25,7 @@ > > ___C(RAW, "Raw device command"), \ > > ___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), \ > > ___C(GET_EVENT_RECORD, "Get Event Record"), \ > > + ___C(CLEAR_EVENT_RECORD, "Clear Event Record"), \ > > ___C(GET_FW_INFO, "Get FW Info"), \ > > ___C(GET_PARTITION_INFO, "Get Partition Information"), \ > > ___C(GET_LSA, "Get Label Storage Area"), \ > > Same, "yikes" / "must be at the end of the enum" feedback. Macro magic makes that non obvious.. Not that I'd ever said I thought this trick was a bad idea ;)