Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2985556ybt; Mon, 29 Jun 2020 12:09:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdsc5S9LkE0NlGigkF+5xSfqQ34TtqTg0o9LasNTpVFkQg28EvAk7XhEweQ9bH0NGajgj2 X-Received: by 2002:a50:f047:: with SMTP id u7mr20163814edl.274.1593457752628; Mon, 29 Jun 2020 12:09:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593457752; cv=none; d=google.com; s=arc-20160816; b=Emm85FGoJK3icrLqRMR72sXN5tkwDbnr2/tlRwu+prWadkiXTd5c13pKPyKW4dO2WG NM3zChCDKYWDSk/YSNiiBDpsnu0CL/zBO1RTDZBgIuzxWBghPVFFqiKxvMNTCAvA9avD fPgCGTf1s88OkW4kpsddMGKeniRAcb11hatimWvtEGUVMX54A9zYMQzgeRhkWpqZXrz2 mP/8a31GkeaKaB+91RZJsvJnoPoWCGreH1WOW6yFvzxDC5wjKn/JQadcdzJNqAtQv6do /AZvdgzUrdaeAeE62i9gr1vzHjdZDSIUiD/lIQ4yNA1L2bHQL8s9ZW6uwpMEjcYc90LP mh7g== 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=7nlhWJJwNwhWkeMdSwXObsiOh2VHz3Q74vTd3L4F/E4=; b=RLQ/Z/VSrDZSArenATlvFifW4KnJ1wg0fNcpO+Ub9r4YNLGdtMmxtYPkfi8BRBXEI/ 0BNEqzn2lkcBHCDCusXOFdQ+4FNX2ujU1YWJQr49sOLXGP4X8w4CdJtFVZ4cBpuUyNgp vbzexfmEEUYPA44C871H1DMDoBdEpextXlRU/RfhMSw2oQDyvAdHp8gZmg427dwOcbqw +Bxro1gHwNqM2Fa6i+IZJdux0BJX6b7zYVBx4P15dXoPlgMgcT6G29qTlW3UuPryM3Rs uqBi2v9SFVU0gFXG5isX9+62uqPjSR25IE9Twnt5ymkenBuYIX/BorG+7Uaua5e9gr0z K9EQ== 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 mb4si306011ejb.173.2020.06.29.12.08.49; Mon, 29 Jun 2020 12:09:12 -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 S1729597AbgF2TGb (ORCPT + 99 others); Mon, 29 Jun 2020 15:06:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41744 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730525AbgF2TCn (ORCPT ); Mon, 29 Jun 2020 15:02:43 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45E39C02A54F; Mon, 29 Jun 2020 06:02:47 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id n5so15423190otj.1; Mon, 29 Jun 2020 06:02:47 -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=7nlhWJJwNwhWkeMdSwXObsiOh2VHz3Q74vTd3L4F/E4=; b=lGDfCfLqwyum+wheMtxLdsXH0kBg80MIs9SllgK3dlDn7I2Hoo8MoBDen1jtsdaAvs pgcCEGXBUBtaIS6g5b1tZsw1sk0+/ATD9U+Yn1qMJ/E4dEi+kWcpGAZyTI/JCnzP0cRc XR1RnL5PwpnVI7ezWGLTCFlRRzWZclbns1W2vNzY+EP0VjlwitiMDDLlxdivoa8i0ER4 6fJSfzPNOkaJ6CxzpdQQAlnd1Om2Z3fow1qjzQTqJvV6fOSfdPaajcdM/LKIi0B9Givj X8Oa2kuKHAVLgvMMjsQS+2h+GiQD98GFYQEt2luBeMjlm1Ig8eQ18hWVa+eQhJIquOVd eX6g== X-Gm-Message-State: AOAM530NYrlYHf+0nzK8xQoU7g74mUSKAppZEL68Ilkrfzdmrhh+AgcC hHg4kOWniClj8vs4n6w9L/BXIw/RG7uE20dyiIBJUwjf X-Received: by 2002:a9d:7d15:: with SMTP id v21mr12817982otn.118.1593435766462; Mon, 29 Jun 2020 06:02:46 -0700 (PDT) MIME-Version: 1.0 References: <158889473309.2292982.18007035454673387731.stgit@dwillia2-desk3.amr.corp.intel.com> <2713141.s8EVnczdoM@kreacher> <13749323.0m2ImmhSHx@kreacher> In-Reply-To: From: "Rafael J. Wysocki" Date: Mon, 29 Jun 2020 15:02:31 +0200 Message-ID: Subject: Re: [RFT][PATCH v2 3/4] ACPICA: Preserve memory opregion mappings if supported by OS To: "Kaneda, Erik" Cc: "Rafael J. Wysocki" , "Williams, Dan J" , "Moore, Robert" , "Wysocki, Rafael J" , Len Brown , Borislav Petkov , "Weiny, Ira" , James Morse , Myron Stowe , Andy Shevchenko , "linux-kernel@vger.kernel.org" , "linux-acpi@vger.kernel.org" , "linux-nvdimm@lists.01.org" 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 Sat, Jun 27, 2020 at 12:53 AM Kaneda, Erik wrote: > > > > > -----Original Message----- > > From: Rafael J. Wysocki > > Sent: Monday, June 22, 2020 7:02 AM > > To: Williams, Dan J ; Kaneda, Erik > > > > Cc: Wysocki, Rafael J ; Len Brown > > ; Borislav Petkov ; Weiny, Ira > > ; James Morse ; Myron > > Stowe ; Andy Shevchenko > > ; linux-kernel@vger.kernel.org; linux- > > acpi@vger.kernel.org; linux-nvdimm@lists.01.org; Moore, Robert > > > > Subject: [RFT][PATCH v2 3/4] ACPICA: Preserve memory opregion mappings > > if supported by OS > > > > From: "Rafael J. Wysocki" > > > > The ACPICA's strategy with respect to the handling of memory mappings > > associated with memory operation regions is to avoid mapping the > > entire region at once which may be problematic at least in principle > > (for example, it may lead to conflicts with overlapping mappings > > having different attributes created by drivers). It may also be > > wasteful, because memory opregions on some systems take up vast > > chunks of address space while the fields in those regions actually > > accessed by AML are sparsely distributed. > > > > For this reason, a one-page "window" is mapped for a given opregion > > on the first memory access through it and if that "window" does not > > cover an address range accessed through that opregion subsequently, > > it is unmapped and a new "window" is mapped to replace it. Next, > > if the new "window" is not sufficient to access memory through the > > opregion in question in the future, it will be replaced with yet > > another "window" and so on. That may lead to a suboptimal sequence > > of memory mapping and unmapping operations, for example if two fields > > in one opregion separated from each other by a sufficiently wide > > chunk of unused address space are accessed in an alternating pattern. > > > > The situation may still be suboptimal if the deferred unmapping > > introduced previously is supported by the OS layer. For instance, > > the alternating memory access pattern mentioned above may produce > > a relatively long list of mappings to release with substantial > > duplication among the entries in it, which could be avoided if > > acpi_ex_system_memory_space_handler() did not release the mapping > > used by it previously as soon as the current access was not covered > > by it. > > > > In order to improve that, modify acpi_ex_system_memory_space_handler() > > to take advantage of the memory mappings reference counting at the OS > > level if a suitable interface is provided. > > > Hi, > > > Namely, if ACPI_USE_FAST_PATH_MAPPING is set, the OS is expected to > > implement acpi_os_map_memory_fast_path() that will return NULL if > > there is no mapping covering the given address range known to it. > > If such a mapping is there, however, its reference counter will be > > incremented and a pointer representing the requested virtual address > > will be returned right away without any additional consequences. > > I do not fully understand why this is under a #ifdef. Is this to support operating systems that might not want to add support for this behavior? Yes, and to protect the ones that have not added support for it just yet. Without the "fast-path" mapping support, ACPICA has no way to obtain additional references to known-existing mappings and the new code won't work as expected without it, so it is better to avoid building that code at all in those cases IMO. > Also, instead of using the terminology fast_path, I think it would be easier to use terminology that describes the mechanism.. > It might be easier for other Operating systems to understand something like acpi_os_map_preserved_memory or acpi_os_map_sysmem_opregion_memory. Well, the naming is not particularly important to me to be honest, but this is mostly about being able to get a new reference to a known-existing memory mapping. So something like acpi_os_ref_memory_map() perhaps? But I'm thinking that this can be implemented without the "fast-path" mapping support too, let me try to do that. Cheers!