From patchwork Mon Dec 3 18:05:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Morse X-Patchwork-Id: 10710207 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 029DB18BC for ; Mon, 3 Dec 2018 18:06:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECE512B495 for ; Mon, 3 Dec 2018 18:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E022C2B48F; Mon, 3 Dec 2018 18:06:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6CCD02B487 for ; Mon, 3 Dec 2018 18:06:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E1946B6A32; Mon, 3 Dec 2018 13:06:56 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 06D1D6B6A78; Mon, 3 Dec 2018 13:06:56 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4EBE6B6A79; Mon, 3 Dec 2018 13:06:55 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) by kanga.kvack.org (Postfix) with ESMTP id B86C56B6A32 for ; Mon, 3 Dec 2018 13:06:55 -0500 (EST) Received: by mail-ot1-f72.google.com with SMTP id w24so5834964otk.22 for ; Mon, 03 Dec 2018 10:06:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-original-authentication-results:x-gm-message-state:from:to:cc :subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=32pQbp1azz8lOuYjiMIPoqSkEvXqXwtpekjbJaSIwMk=; b=FFkrjHchsoGQs1R0RECCws3yvURYFSpNI8nPtWJSJR5ffhrU6ai6AIA1KwefrRaoQ3 MCnQLL6kWlOxkQSS3Erpt4o9OJAOXPQKi0dwRmv6NNKxjYWpreyPaaB0S3RwSl/+LnN+ jTYvE38f3B3euNV39P/0rHugFDJmjFQeF85tfxrWO2f51q7YtzuYoU5nFspVkUVtRv1G JOttfnCLjQZfgxdn6fW8OldK+p9VZVGy3Xr95JWD9RhWS8s3iYsP8uZvbq14LkKdqR+r neC3mOzR8riZFoXTpnpHOc1akd7vwAiQMPvFxFY0oFyLlj1OljxEtQu/IbnymhjP/un+ EKuw== X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com X-Gm-Message-State: AA+aEWY3+rjxQlNMRoA0pAKpdGeGyEWyxuagK42E7KYLxhhyhqqfaCHH JlsabpHJrgs0b1uDoBe9XKPIHWZxidLMU8QeZE9cs2JUBqXEgnS15org6LxUrFD+yfIdCSF97Kf GpzeK5ETwXMEIzTVEZFbbALM5SWE99oY1n9TyzLAfhX3KhaaiqDqT9p/oibuWzG443A== X-Received: by 2002:a9d:177:: with SMTP id 110mr11104702otu.26.1543860415442; Mon, 03 Dec 2018 10:06:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/VnhIOzEC61CmMLsSZn/nsT2V0VRsOOfLh1HNIm+4ULEeIdJ/qTPByZLnUZMatNRZFEvMBR X-Received: by 2002:a9d:177:: with SMTP id 110mr11104644otu.26.1543860414247; Mon, 03 Dec 2018 10:06:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543860414; cv=none; d=google.com; s=arc-20160816; b=mLs1EZ6+/PUv0kXTYhUzsyMRLtj5RIAwRjO4Lvhe3e92STKRBa+/5MCp89jh9hi054 zBla0va3yG9osVCheOUu6Zrs0osH44+yHPjyr3kW37Eyzmp8dg5hlshlKcmJRZsp0mmW 7VaL8oNUY+820eI9CBPmN2yAIeXMafKAR08WGcC73WF9ZaY1jg+fVohFKH/S9A+b0NHy MOHDdhNWHB+Xd9PwQK8mDNbViseaUxzgIw6ieNwzsp9lg/k++ufcgpEUd3t9y4+432N/ 794Sd/XGlErD+P0Kq44VUJ6HBTKzsT5/gleNhz/+C3vVfWrgUvQekA2RDFMuSCCQfe+/ UoIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=32pQbp1azz8lOuYjiMIPoqSkEvXqXwtpekjbJaSIwMk=; b=Woy4iBXUhsWVMyYq/s/M0kpNQNjpHBQrKqskpw2nKquB3ytdfVayfeG5DaGcWg9s7/ 8Rnw+sLbesbVIbGnemrC1pDV7fyMc0gwPE9jxicR5aGVU4cEeuegvx8BhYkUI6ZRIKzo lCu9R95nLXYRsaMEdLTn5Uhd+0zETzCUFeYs+ZOp0xvxZqKTyD4QW4eSIOxF0CRhsqif 0Mh1YQEgLPXcUKh8QisbJfcocq8QP3+jcxigl8S5A/P71yZUAXqz2Hv57jrFfjMPOOIv U/CjWNJnXSEJoWwOx/2smcbRGTbbjz+YkLeoD10g7Tf7woHeAWLRB4SBtjstyj/24bxF wlfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from foss.arm.com (usa-sjc-mx-foss1.foss.arm.com. [217.140.101.70]) by mx.google.com with ESMTP id y23si7282604otj.129.2018.12.03.10.06.53 for ; Mon, 03 Dec 2018 10:06:54 -0800 (PST) Received-SPF: pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) client-ip=217.140.101.70; Authentication-Results: mx.google.com; spf=pass (google.com: domain of james.morse@arm.com designates 217.140.101.70 as permitted sender) smtp.mailfrom=james.morse@arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 8BDD21682; Mon, 3 Dec 2018 10:06:53 -0800 (PST) Received: from eglon.cambridge.arm.com (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BB7543F59C; Mon, 3 Dec 2018 10:06:50 -0800 (PST) From: James Morse To: linux-acpi@vger.kernel.org Cc: kvmarm@lists.cs.columbia.edu, linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Borislav Petkov , Marc Zyngier , Christoffer Dall , Will Deacon , Catalin Marinas , Naoya Horiguchi , Rafael Wysocki , Len Brown , Tony Luck , Dongjiu Geng , Xie XiuQi , Fan Wu , James Morse Subject: [PATCH v7 05/25] ACPI / APEI: Make estatus pool allocation a static size Date: Mon, 3 Dec 2018 18:05:53 +0000 Message-Id: <20181203180613.228133-6-james.morse@arm.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20181203180613.228133-1-james.morse@arm.com> References: <20181203180613.228133-1-james.morse@arm.com> MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: X-Virus-Scanned: ClamAV using ClamSMTP Adding new NMI-like notifications duplicates the calls that grow and shrink the estatus pool. This is all pretty pointless, as the size is capped to 64K. Allocate this for each ghes and drop the code that grows and shrinks the pool. Suggested-by: Borislav Petkov Signed-off-by: James Morse Reviewed-by: Borislav Petkov --- drivers/acpi/apei/ghes.c | 49 +++++----------------------------------- drivers/acpi/apei/hest.c | 2 +- include/acpi/ghes.h | 2 +- 3 files changed, 8 insertions(+), 45 deletions(-) diff --git a/drivers/acpi/apei/ghes.c b/drivers/acpi/apei/ghes.c index 78058adb2574..7c2e9ac140d4 100644 --- a/drivers/acpi/apei/ghes.c +++ b/drivers/acpi/apei/ghes.c @@ -162,27 +162,18 @@ static void ghes_iounmap_irq(void) clear_fixmap(FIX_APEI_GHES_IRQ); } -static int ghes_estatus_pool_expand(unsigned long len); //temporary - -int ghes_estatus_pool_init(void) +int ghes_estatus_pool_init(int num_ghes) { + unsigned long addr, len; + ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1); if (!ghes_estatus_pool) return -ENOMEM; - return ghes_estatus_pool_expand(GHES_ESTATUS_CACHE_AVG_SIZE * - GHES_ESTATUS_CACHE_ALLOCED_MAX); -} - -static int ghes_estatus_pool_expand(unsigned long len) -{ - unsigned long size, addr; - - ghes_estatus_pool_size_request += PAGE_ALIGN(len); - size = gen_pool_size(ghes_estatus_pool); - if (size >= ghes_estatus_pool_size_request) - return 0; + len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX; + len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE); + ghes_estatus_pool_size_request = PAGE_ALIGN(len); addr = (unsigned long)vmalloc(PAGE_ALIGN(len)); if (!addr) return -ENOMEM; @@ -954,32 +945,8 @@ static int ghes_notify_nmi(unsigned int cmd, struct pt_regs *regs) return ret; } -static unsigned long ghes_esource_prealloc_size( - const struct acpi_hest_generic *generic) -{ - unsigned long block_length, prealloc_records, prealloc_size; - - block_length = min_t(unsigned long, generic->error_block_length, - GHES_ESTATUS_MAX_SIZE); - prealloc_records = max_t(unsigned long, - generic->records_to_preallocate, 1); - prealloc_size = min_t(unsigned long, block_length * prealloc_records, - GHES_ESOURCE_PREALLOC_MAX_SIZE); - - return prealloc_size; -} - -static void ghes_estatus_pool_shrink(unsigned long len) -{ - ghes_estatus_pool_size_request -= PAGE_ALIGN(len); -} - static void ghes_nmi_add(struct ghes *ghes) { - unsigned long len; - - len = ghes_esource_prealloc_size(ghes->generic); - ghes_estatus_pool_expand(len); mutex_lock(&ghes_list_mutex); if (list_empty(&ghes_nmi)) register_nmi_handler(NMI_LOCAL, ghes_notify_nmi, 0, "ghes"); @@ -989,8 +956,6 @@ static void ghes_nmi_add(struct ghes *ghes) static void ghes_nmi_remove(struct ghes *ghes) { - unsigned long len; - mutex_lock(&ghes_list_mutex); list_del_rcu(&ghes->list); if (list_empty(&ghes_nmi)) @@ -1001,8 +966,6 @@ static void ghes_nmi_remove(struct ghes *ghes) * freed after NMI handler finishes. */ synchronize_rcu(); - len = ghes_esource_prealloc_size(ghes->generic); - ghes_estatus_pool_shrink(len); } static void ghes_nmi_init_cxt(void) diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index da5fabaeb48f..66e1e2fd7bc4 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c @@ -201,7 +201,7 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count) if (!ghes_arr.ghes_devs) return -ENOMEM; - rc = ghes_estatus_pool_init(); + rc = ghes_estatus_pool_init(ghes_count); if (rc) goto out; diff --git a/include/acpi/ghes.h b/include/acpi/ghes.h index 46ef5566e052..cd9ee507d860 100644 --- a/include/acpi/ghes.h +++ b/include/acpi/ghes.h @@ -52,7 +52,7 @@ enum { GHES_SEV_PANIC = 0x3, }; -int ghes_estatus_pool_init(void); +int ghes_estatus_pool_init(int num_ghes); /* From drivers/edac/ghes_edac.c */