From patchwork Wed Jan 29 10:16:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Durrant X-Patchwork-Id: 11355805 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A722292A for ; Wed, 29 Jan 2020 10:18:07 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 83F2A2064C for ; Wed, 29 Jan 2020 10:18:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="OT0YssY6" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 83F2A2064C Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iwkP8-0003nU-To; Wed, 29 Jan 2020 10:17:02 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iwkP7-0003mt-H3 for xen-devel@lists.xenproject.org; Wed, 29 Jan 2020 10:17:01 +0000 X-Inumbo-ID: 7d380fdc-4280-11ea-a933-bc764e2007e4 Received: from smtp-fw-4101.amazon.com (unknown [72.21.198.25]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 7d380fdc-4280-11ea-a933-bc764e2007e4; Wed, 29 Jan 2020 10:17:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1580293021; x=1611829021; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=evDAGUGw+zz54gSMl7Q0673Sft+/nZsV640lVr+GpD4=; b=OT0YssY68TU2Zg2klJINxdASeC7H1OHRIK3jBiUNjDcNLaWsdSZg2+tl T8yCaXJV1ocHmEj1wcxHY/kDfc/2mC8XzLGCScEveIfahoor8wpHbAYhV ohboGTEj9i8kFLBorm0+oO7Vd9P1YX2oAU1F0h/9sNpSyJBW8NjLbazPn s=; IronPort-SDR: 07q+lMAS9ijgcHpNEHUSdq7LClwHb0+IlRl20axSnGjCI/NtnpbG+tBWOGK5xV0dL2RnH7bzxk T18CBQGg6Zqg== X-IronPort-AV: E=Sophos;i="5.70,377,1574121600"; d="scan'208";a="14656024" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2a-22cc717f.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-4101.iad4.amazon.com with ESMTP; 29 Jan 2020 10:16:59 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan3.pdx.amazon.com [10.170.41.166]) by email-inbound-relay-2a-22cc717f.us-west-2.amazon.com (Postfix) with ESMTPS id 52EA2A1CA4; Wed, 29 Jan 2020 10:16:58 +0000 (UTC) Received: from EX13D32EUC003.ant.amazon.com (10.43.164.24) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1236.3; Wed, 29 Jan 2020 10:16:58 +0000 Received: from EX13MTAUEA001.ant.amazon.com (10.43.61.82) by EX13D32EUC003.ant.amazon.com (10.43.164.24) with Microsoft SMTP Server (TLS) id 15.0.1367.3; Wed, 29 Jan 2020 10:16:56 +0000 Received: from u2f063a87eabd5f.cbg10.amazon.com (10.125.106.135) by mail-relay.amazon.com (10.43.61.243) with Microsoft SMTP Server id 15.0.1367.3 via Frontend Transport; Wed, 29 Jan 2020 10:16:54 +0000 From: Paul Durrant To: Date: Wed, 29 Jan 2020 10:16:41 +0000 Message-ID: <20200129101643.1394-3-pdurrant@amazon.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200129101643.1394-1-pdurrant@amazon.com> References: <20200129101643.1394-1-pdurrant@amazon.com> MIME-Version: 1.0 Precedence: Bulk Subject: [Xen-devel] [PATCH v5 2/4] mm: modify domain_adjust_tot_pages() to better handle a zero adjustment X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Paul Durrant , Ian Jackson Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Currently the function will pointlessly acquire and release the global 'heap_lock' in this case. NOTE: No caller yet calls domain_adjust_tot_pages() with a zero 'pages' argument, but a subsequent patch will make this possible. Signed-off-by: Paul Durrant --- Cc: Andrew Cooper Cc: George Dunlap Cc: Ian Jackson Cc: Jan Beulich Cc: Julien Grall Cc: Konrad Rzeszutek Wilk Cc: Stefano Stabellini Cc: Wei Liu v5: - Split out from the subsequent 'make MEMF_no_refcount pages safe to assign' patch as requested by Jan --- xen/common/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 919a270587..135e15bae0 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -460,6 +460,9 @@ unsigned long domain_adjust_tot_pages(struct domain *d, long pages) { long dom_before, dom_after, dom_claimed, sys_before, sys_after; + if ( !pages ) + goto out; + ASSERT(spin_is_locked(&d->page_alloc_lock)); d->tot_pages += pages;