From patchwork Wed Mar 16 14:11:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Douglas Goldstein X-Patchwork-Id: 8600911 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A4B589F294 for ; Wed, 16 Mar 2016 14:13:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA80A202F2 for ; Wed, 16 Mar 2016 14:13:52 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C4BA02034B for ; Wed, 16 Mar 2016 14:13:49 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agCAR-0000hK-2Q; Wed, 16 Mar 2016 14:11:19 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1agCAQ-0000gp-IR for xen-devel@lists.xen.org; Wed, 16 Mar 2016 14:11:18 +0000 Received: from [85.158.139.211] by server-1.bemta-5.messagelabs.com id E1/6E-29419-58969E65; Wed, 16 Mar 2016 14:11:17 +0000 X-Env-Sender: cardoe@cardoe.com X-Msg-Ref: server-4.tower-206.messagelabs.com!1458137476!29471548!1 X-Originating-IP: [209.85.161.193] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.11; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27474 invoked from network); 16 Mar 2016 14:11:17 -0000 Received: from mail-yw0-f193.google.com (HELO mail-yw0-f193.google.com) (209.85.161.193) by server-4.tower-206.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 16 Mar 2016 14:11:17 -0000 Received: by mail-yw0-f193.google.com with SMTP id f6so3683683ywa.1 for ; Wed, 16 Mar 2016 07:11:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cardoe.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=tDaaNr5ULTg3Pfym8pppg6QOxFEM0Da/ND9XYQPl6bE=; b=E6UxCTOr0yE+Rwjxild2IOQM1pmtXwezVo27wnyywQ1GFgNqM/VsJHYSzTSeCdpkbh dyFDYwhCt5rlZP0QBvMdqs/la4FcxBa71O/9cv5fArEgtrK1XevblbU1CqsR0MYgh3b9 fwBRbR8NTug5n2ojr2+tTJX6jweHof8ZfxIk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=tDaaNr5ULTg3Pfym8pppg6QOxFEM0Da/ND9XYQPl6bE=; b=WLwW27gfSSLOiZ2Z0FXeh/YYtybFWkPsoNoinDMQtLNe2uj2bNbatINYBpHkgUASRg ZCU4jaAPrYnx/NLA5WWJkETj0HSyQp3AlttBSW2AmQ2dVKP5JVf2dyL4qMsyk5NBpX3A wSozvmMTuVIXaRqIdsA34UAifvfqnUM4fWHRN9541ZHbMOyBi0gaRVzCgznUYAM06vz3 jiYd6MQtixAw8nfjRXA5h9WfSJmeO6XWJ/jbv3gY5PzlbhGg689VkT1kZX8h2m4Uwjk1 sYj1NOQhbifHJgYKKgSmHQ2OAg+gWpNGg3y+IJiglebS5lp4qbtK7LU+V8eWj5y86kBD bMLg== X-Gm-Message-State: AD7BkJLRf+/WPcP3C3/8uJPYud0BXB+MBvLEHFBz4i2ZcS95DlcCrAZNFPmx/X8X2sTWRw== X-Received: by 10.129.120.133 with SMTP id t127mr1826120ywc.204.1458137476046; Wed, 16 Mar 2016 07:11:16 -0700 (PDT) Received: from swanson.lan (c-68-46-196-185.hsd1.al.comcast.net. [68.46.196.185]) by smtp.gmail.com with ESMTPSA id a140sm1937862ywe.50.2016.03.16.07.11.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Mar 2016 07:11:15 -0700 (PDT) From: Doug Goldstein To: xen-devel@lists.xen.org Date: Wed, 16 Mar 2016 09:11:00 -0500 Message-Id: <1458137461-3535-3-git-send-email-cardoe@cardoe.com> X-Mailer: git-send-email 2.4.10 In-Reply-To: <1458137461-3535-1-git-send-email-cardoe@cardoe.com> References: <1458137461-3535-1-git-send-email-cardoe@cardoe.com> Cc: Keir Fraser , Doug Goldstein , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v3 2/3] tmem: drop direct usage of opt_tmem X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Spam-Status: No, score=-0.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_BL_SPAMCOP_NET, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most callers of tmem_freeable_pages() checked to see if by checking opt_tmem before calling tmem_freeable_pages() but not all of them did. This seemed like an oversight and to avoid similar situations like that, stick the check of tmem into tmem_freeable_pages(). Similarly other places should not directly check opt_tmem but instead use the tmem_enabled() helper function. Signed-off-by: Doug Goldstein Acked-by: Jan Beulich --- CC: Keir Fraser CC: Jan Beulich CC: Andrew Cooper CC: Konrad Rzeszutek Wilk change since v2: - merged commit message from patch 2 and 3 change since v1: - merged patch 2 and 3 --- xen/arch/x86/setup.c | 2 +- xen/common/memory.c | 2 +- xen/common/page_alloc.c | 8 ++++---- xen/common/tmem.c | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c index 5011930..c5c332d 100644 --- a/xen/arch/x86/setup.c +++ b/xen/arch/x86/setup.c @@ -1272,7 +1272,7 @@ void __init noreturn __start_xen(unsigned long mbi_p) init_domheap_pages(s, e); } - if ( opt_tmem ) + if ( tmem_enabled() ) { printk(XENLOG_WARNING "TMEM physical RAM limit exceeded, disabling TMEM\n"); diff --git a/xen/common/memory.c b/xen/common/memory.c index ef57219..c7fca96 100644 --- a/xen/common/memory.c +++ b/xen/common/memory.c @@ -202,7 +202,7 @@ static void populate_physmap(struct memop_args *a) if ( unlikely(!page) ) { - if ( !opt_tmem || a->extent_order ) + if ( !tmem_enabled() || a->extent_order ) gdprintk(XENLOG_INFO, "Could not allocate order=%u extent: id=%d memflags=%#x (%u of %u)\n", a->extent_order, d->domain_id, a->memflags, diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 22e8feb..98e30e5 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -652,7 +652,7 @@ static void __init setup_low_mem_virq(void) static void check_low_mem_virq(void) { unsigned long avail_pages = total_avail_pages + - (opt_tmem ? tmem_freeable_pages() : 0) - outstanding_claims; + tmem_freeable_pages() - outstanding_claims; if ( unlikely(avail_pages <= low_mem_virq_th) ) { @@ -738,7 +738,7 @@ static struct page_info *alloc_heap_pages( * Others try tmem pools then fail. This is a workaround until all * post-dom0-creation-multi-page allocations can be eliminated. */ - if ( opt_tmem && ((order == 0) || (order >= 9)) && + if ( ((order == 0) || (order >= 9)) && (total_avail_pages <= midsize_alloc_zone_pages) && tmem_freeable_pages() ) goto try_tmem; @@ -984,7 +984,7 @@ static void free_heap_pages( avail[node][zone] += 1 << order; total_avail_pages += 1 << order; - if ( opt_tmem ) + if ( tmem_enabled() ) midsize_alloc_zone_pages = max( midsize_alloc_zone_pages, total_avail_pages / MIDSIZE_ALLOC_FRAC); @@ -1755,7 +1755,7 @@ int assign_pages( { if ( unlikely((d->tot_pages + (1 << order)) > d->max_pages) ) { - if ( !opt_tmem || order != 0 || d->tot_pages != d->max_pages ) + if ( !tmem_enabled() || order != 0 || d->tot_pages != d->max_pages ) gprintk(XENLOG_INFO, "Over-allocation for domain %u: " "%u > %u\n", d->domain_id, d->tot_pages + (1 << order), d->max_pages); diff --git a/xen/common/tmem.c b/xen/common/tmem.c index 0436e49..16e249a 100644 --- a/xen/common/tmem.c +++ b/xen/common/tmem.c @@ -2837,6 +2837,9 @@ void *tmem_relinquish_pages(unsigned int order, unsigned int memflags) unsigned long tmem_freeable_pages(void) { + if ( !tmem_enabled() ) + return 0; + return tmem_page_list_pages + _atomic_read(freeable_page_count); }