Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp7224393rwb; Tue, 6 Dec 2022 03:00:26 -0800 (PST) X-Google-Smtp-Source: AA0mqf7HL6tHVVOjS/EWz5Q5uVeNTXMCEv5IZg8myTfKbzZyaB23BISoV3SSkIM8lf4py2se5fAa X-Received: by 2002:a17:906:f157:b0:7c0:b0fe:263a with SMTP id gw23-20020a170906f15700b007c0b0fe263amr18368161ejb.496.1670324422958; Tue, 06 Dec 2022 03:00:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670324422; cv=none; d=google.com; s=arc-20160816; b=O1cvMEAz88Qi+Hwr/NImx5EmIE98Cs8NpDNJfPHEiE2GhOwyc87a26s2SgAB4rSRjO p/KT3jNllDoPXZNRCyays5Zz61hzYcNOoRG+uevU4JYAEriK+WB93A7luEoAGkiIdg+e fkAHuh730L1nV19NlbBULBklGPzk9+NeY0Uouz11OupEVqz9D4LRHnXtfwCoEJqtoqZE 66Ipg8ytCymyBFxBzfYb0SpdbbkWH3nTUP1ODVTbq4f6p8kvCAYaNaLxjl5YoSgOn/7b SKf/NP3PaPEHQmSZqAT3pCtoq/DhdfaIPskov8UXuDCVuKObCBIGn9P0tSBZuyvd/92+ KsGA== 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=hYWWYAHn/3QP4M896e0DBtsEDAgJ7hiD4cBFbWzPrhA=; b=kScl26SpCLVM9T3UPFEYXcaF3Dg/7eRGDbgzYNJTVwv1Se4s+AXGab8MTqWz51D5cf c1tCbQlKiwIV5D9935B7rDlaUxWgqX6NUAUhKGvHux+56vZ+lySFZwS59rr7YQGZmOwS 20FR4np4fuOtqpMAlJL3njNi925rfi5tqInZq0ZYYwPn3p+WyOHzYFCqHwMTM7NMWkfE RFbUCX7OYavPqL95oqwnKF6Vz0HEDOxDznRR/sl2T4DSyJaGzQmm0Wil3VdWnepPJBD2 vTSAxakf4M656nIeGF7giNAbLG/aNE4rJG/5OeINdoukejfoJvTzAsiDYAdiGAZ1XcZi FNYg== 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 e4-20020a17090658c400b0078e27f2ef4bsi14351303ejs.956.2022.12.06.03.00.03; Tue, 06 Dec 2022 03:00:22 -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 S234716AbiLFJia (ORCPT + 79 others); Tue, 6 Dec 2022 04:38:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234609AbiLFJiZ (ORCPT ); Tue, 6 Dec 2022 04:38:25 -0500 Received: from frasgout.his.huawei.com (frasgout.his.huawei.com [185.176.79.56]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA98E1CFF9; Tue, 6 Dec 2022 01:38:19 -0800 (PST) Received: from lhrpeml500005.china.huawei.com (unknown [172.18.147.226]) by frasgout.his.huawei.com (SkyGuard) with ESMTP id 4NRFdR5tPZz6H7X0; Tue, 6 Dec 2022 17:35:23 +0800 (CST) Received: from localhost (10.45.155.47) 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; Tue, 6 Dec 2022 09:38:16 +0000 Date: Tue, 6 Dec 2022 09:38:15 +0000 From: Jonathan Cameron To: Dan Williams CC: , Alison Schofield , Vishal Verma , Ben Widawsky , Steven Rostedt , "Davidlohr Bueso" , Dave Jiang , , Subject: Re: [PATCH V2 08/11] cxl/mem: Wire up event interrupts Message-ID: <20221206093815.00000156@Huawei.com> In-Reply-To: <638e1dd6aa7bb_25af829435@dwillia2-mobl3.amr.corp.intel.com.notmuch> References: <20221201002719.2596558-1-ira.weiny@intel.com> <20221201002719.2596558-9-ira.weiny@intel.com> <6389ab5156083_c9572947c@dwillia2-mobl3.amr.corp.intel.com.notmuch> <20221202141901.00003016@Huawei.com> <638a55611405d_3cbe02942c@dwillia2-xfh.jf.intel.com.notmuch> <20221205130129.00000cc1@Huawei.com> <638e1dd6aa7bb_25af829435@dwillia2-mobl3.amr.corp.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.45.155.47] X-ClientProxiedBy: lhrpeml500004.china.huawei.com (7.191.163.9) 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 Mon, 5 Dec 2022 08:35:34 -0800 Dan Williams wrote: > Jonathan Cameron wrote: > > On Fri, 2 Dec 2022 11:43:29 -0800 > > Dan Williams wrote: > > > > > Jonathan Cameron wrote: > > > > > > > > > > +int cxl_event_config_msgnums(struct cxl_dev_state *cxlds, > > > > > > + struct cxl_event_interrupt_policy *policy) > > > > > > +{ > > > > > > + int rc; > > > > > > + > > > > > > + policy->info_settings = CXL_INT_MSI_MSIX; > > > > > > + policy->warn_settings = CXL_INT_MSI_MSIX; > > > > > > + policy->failure_settings = CXL_INT_MSI_MSIX; > > > > > > + policy->fatal_settings = CXL_INT_MSI_MSIX; > > > > > > > > > > I think this needs to be careful not to undo events that the BIOS > > > > > steered to itself in firmware-first mode, which raises another question, > > > > > does firmware-first mean more the OS needs to backoff on some event-log > > > > > handling as well? > > > > > > > > Hmm. Does the _OSC cover these. There is one for Memory error reporting > > > > that I think covers it (refers to 12.2.3.2) > > > > > > > > Note that should cover any means of obtaining these, not just interrupt > > > > driven - so including the initial record clear. > > > > > > > > .. > > > > > > > > > > + > > > > > > +static irqreturn_t cxl_event_failure_thread(int irq, void *id) > > > > > > +{ > > > > > > + struct cxl_dev_state *cxlds = id; > > > > > > + > > > > > > + cxl_mem_get_records_log(cxlds, CXL_EVENT_TYPE_FAIL); > > > > > > + return IRQ_HANDLED; > > > > > > +} > > > > > > > > > > So I think one of the nice side effects of moving log priorty handling > > > > > inside of cxl_mem_get_records_log() and looping through all log types in > > > > > priority order until all status is clear is that an INFO interrupt also > > > > > triggers a check of the FATAL status for free. > > > > > > > > > > > > > I go the opposite way on this in thinking that an interrupt should only > > > > ever be used to handle the things it was registered for - so we should > > > > not be clearing fatal records in the handler triggered for info events. > > > > > > I would agree with you if this was a fast path and if the hardware > > > mechanism did not involve shared status register that tells you > > > that both FATAL and INFO are pending retrieval through a mechanism. > > > Compare that to the separation between admin and IO queues in NVME. > > > > > > If the handler is going to loop on the status register then it must be > > > careful not to starve out FATAL while processing INFO. > > > > > > > Doing other actions like this relies on subtlies of the generic interrupt > > > > handling code which happens to force interrupt threads on a shared interrupt > > > > line to be serialized. I'm not sure we are safe at all the interrupt > > > > isn't shared unless we put a lock around the whole thing (we have one > > > > because of the buffer mutex though). > > > > > > The interrupt is likely shared since there is no performance benefit to > > > entice hardware vendors spend transistor budget on more vector space for > > > events. The events architecture does not merit that spend. > > > > > > > If going this way I think the lock needs a rename. > > > > It's not just protecting the buffer used, but also serialize multiple > > > > interrupt threads. > > > > > > I will let Ira decide if he wants to rename, but in my mind the shared > > > event buffer *is* the data being locked, the fact that multiple threads > > > might be contending for it is immaterial. > > > > It isn't he only thing being protected. Access to the device is also > > being serialized including the data in it's registers. > > > > If someone comes along later and decides to implement multiple buffers > > and there for gets rid of the lock. boom. > > That's what the mailbox mutex is protecting against. If there is an > aspect of the hardware state that is not protected by that then that's a > bug. > Wrong level of locking. This is about a race on multiple commands 1) Read data from interrupt thread 1. 2) Read same data from interrupt thread 2. 3) Clear data from interrupt thread 1. 4) Clear data from interrupt thread 2. Boom (well minor error we probably eat but not good practice).