Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp2744984ybg; Fri, 5 Jun 2020 23:58:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzfJcusjyJcHlGEcKj+2c9T7LScma2O9YUVG+tpt6Dk7qT37QQj2ZCMFkrpQzKPBC7nTLvk X-Received: by 2002:a17:907:9d3:: with SMTP id bx19mr11601142ejc.461.1591426718476; Fri, 05 Jun 2020 23:58:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591426718; cv=none; d=google.com; s=arc-20160816; b=pjAmWk+NCe/GR9WMViVtS0oWVWtssHEo2G53XnQ49HD4MbZkDQnbyMK1XFnH373gIG kjVZkgXX2PV6x+7tAVl0ba2dw7CK95wG+Y+QmkJ0ldbGv1+ZpUWYvC7ATnqqfV1ErGt4 H1RBBweQtL9rUUBKQF3c0MEsKORmimhYaHIBS01bi6CZ1PEQ5T+QJvIjn2jDKLCAxTJk 7XUPVh4qbzW/oSSow6fdFhDcPb4xaUX2WGSOew9w8aUFjlUVbMRQ3qt3VxTVgNKFo5f/ oo6Ew+Ynd4Ix56qD8gRRd0+DqaFH66Tn4vHAYPwRgKGwfhn/DSVU/uKP4E+RLoj+PvFY 7elg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=NQUek8YBI/Ra2tT9dStFeBAAq+j/b7SMm32naih+7IE=; b=ipAqdsUGzxoAh6UCeR/CbvH2QK1WvFDGfEnwjtLIKvtTTp1PWXv6qn9QSnuT4hcfG/ h2fREGAAhqAbPM1MrUCQlNTCyUKT35L1ukn+vc6l5jGpzLpKtpWGijNLAxA4tMTR1hYX JBNXbrl5fZqxR7TtjraRx5avD+vLEkmb7YyYy1wq7F0st7yugonXjsNliVz70zWqbcuu vlDzu7D3lWCUo09IIS/Z8k8Ezz2NhxdSrO2Z68SZsLUQGj1fsNN5r1E6SunAVdgzRXCe CM065BdQCSv9yrAjotPjPbBqYuHlE69Gm3hwCx6LyqUDOTCZPTESYVH4h3XZhKb9NyzX PfDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f6si5017258ejr.283.2020.06.05.23.58.16; Fri, 05 Jun 2020 23:58:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728584AbgFFG4i (ORCPT + 99 others); Sat, 6 Jun 2020 02:56:38 -0400 Received: from mail-ot1-f65.google.com ([209.85.210.65]:36917 "EHLO mail-ot1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726384AbgFFG4i (ORCPT ); Sat, 6 Jun 2020 02:56:38 -0400 Received: by mail-ot1-f65.google.com with SMTP id v13so9492439otp.4; Fri, 05 Jun 2020 23:56:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=NQUek8YBI/Ra2tT9dStFeBAAq+j/b7SMm32naih+7IE=; b=g/BNmS+nt1Hp+fI8wygGKZZ1JIRr4HE9IHnBqVxgEKDJySHqbeDQxSfjQIhP5FcbdN KVc97Vb4AyBmhnOOClfcnKiayarjgrjJ9BbhiT50tW8Gn3oohVRbMEyG/IrCVB1i5cLJ VcsVDVv8Owun+4hawVDlgTloiEi15pmhnnlUPy0GOH0pFwZ9oYRGLxrr5BF4H/DeGr+T gL04O6KNEyhCIiTe/S0FLNJaZzEmuyLkSNlqmnhk508fm0T/o0vXm2W2/fwTzDe1rzR4 wrCGx37dfjhRivYHKfMwnYJtx+b0GyeHgvXOLS3CcB4uMJR0nzh0PnioTvtj/w7BN+8y 7fkA== X-Gm-Message-State: AOAM530PjjDwz36RiqoEWTQaGxJjY5fDckZVKuQE0/MOgh3s9d6MDoTO QBPuM+UPwbQEU0QPxoK1xwsRpbSpU0ugH4snnYk= X-Received: by 2002:a9d:39f5:: with SMTP id y108mr3763834otb.262.1591426597228; Fri, 05 Jun 2020 23:56:37 -0700 (PDT) MIME-Version: 1.0 References: <158889473309.2292982.18007035454673387731.stgit@dwillia2-desk3.amr.corp.intel.com> <2643462.teTRrieJB7@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Sat, 6 Jun 2020 08:56:26 +0200 Message-ID: Subject: Re: [RFT][PATCH] ACPI: OSL: Use rwlock instead of RCU for memory management To: Dan Williams Cc: "Rafael J. Wysocki" , Rafael J Wysocki , stable , Len Brown , Borislav Petkov , Ira Weiny , James Morse , Erik Kaneda , Myron Stowe , Andy Shevchenko , Linux Kernel Mailing List , Linux ACPI , linux-nvdimm Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 5, 2020 at 7:09 PM Dan Williams wrote: > > On Fri, Jun 5, 2020 at 7:06 AM Rafael J. Wysocki wrote: > > > > From: Rafael J. Wysocki > > Subject: [PATCH] ACPI: OSL: Use rwlock instead of RCU for memory management > > > > The ACPI OS layer uses RCU to protect the list of ACPI memory > > mappings from being walked while it is updated. Among other > > situations, that list can be walked in non-NMI interrupt context, > > so using a sleeping lock to protect it is not an option. > > > > However, performance issues related to the RCU usage in there > > appear, as described by Dan Williams: > > > > "Recently a performance problem was reported for a process invoking > > a non-trival ASL program. The method call in this case ends up > > repetitively triggering a call path like: > > > > acpi_ex_store > > acpi_ex_store_object_to_node > > acpi_ex_write_data_to_field > > acpi_ex_insert_into_field > > acpi_ex_write_with_update_rule > > acpi_ex_field_datum_io > > acpi_ex_access_region > > acpi_ev_address_space_dispatch > > acpi_ex_system_memory_space_handler > > acpi_os_map_cleanup.part.14 > > _synchronize_rcu_expedited.constprop.89 > > schedule > > > > The end result of frequent synchronize_rcu_expedited() invocation is > > tiny sub-millisecond spurts of execution where the scheduler freely > > migrates this apparently sleepy task. The overhead of frequent > > scheduler invocation multiplies the execution time by a factor > > of 2-3X." > > > > In order to avoid these issues, replace the RCU in the ACPI OS > > layer by an rwlock. > > > > That rwlock should not be frequently contended, so the performance > > impact of it is not expected to be significant. > > > > Reported-by: Dan Williams > > Signed-off-by: Rafael J. Wysocki > > --- > > > > Hi Dan, > > > > This is a possible fix for the ACPI OSL RCU-related performance issues, but > > can you please arrange for the testing of it on the affected systems? > > Ugh, is it really this simple? I did not realize the read-side is NMI > safe. I'll take a look. But if an NMI triggers while the lock is being held for writing, it will deadlock, won't it? OTOH, according to the RCU documentation it is valid to call rcu_read_[un]lock() from an NMI handler (see Interrupts and NMIs in Documentation/RCU/Design/Requirements/Requirements.rst) so we are good from this perspective today. Unless we teach APEI to avoid mapping lookups from apei_{read|write}(), which wouldn't be unreasonable by itself, we need to hold on to the RCU in ACPI OSL, so it looks like addressing the problem in ACPICA is the best way to do it (and the current ACPICA code in question is suboptimal, so it would be good to rework it anyway). Cheers!