From patchwork Mon Sep 16 14:41:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1162953 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gGctzBmD"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46X9KS1sk0z9sPq for ; Tue, 17 Sep 2019 01:34:52 +1000 (AEST) Received: from localhost ([::1]:35956 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9t1d-0007Dk-Hv for incoming@patchwork.ozlabs.org; Mon, 16 Sep 2019 11:34:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53617) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i9sCq-0006Lr-9g for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i9sCo-0007Qy-77 for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:19 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]:39492) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1i9sCn-0007QZ-RL for qemu-devel@nongnu.org; Mon, 16 Sep 2019 10:42:18 -0400 Received: by mail-wm1-x32a.google.com with SMTP id v17so67965wml.4 for ; Mon, 16 Sep 2019 07:42:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=+yIB4TtQhEbL/mvyJX2uAbbwQXERvRXJT6x1cyUEp28=; b=gGctzBmDa0dX/K+PN9zIT/2Cyfz2c9jVUZVsmnAzkqtqU96ioIRFWLTFWtaf/FY4kQ 0WvygNVjnhczvv1DUdL6ZqTXRKQ+9P+MZBIXnRnSR/Jo7isP/DN4f636YPhzpe3L3QlL bEjSt9Uaguc5XxAkk43E5ynmqKhJp5dR5rax0p4M7o94AhOGwb0ra/61LR8+ibkRu+hT 12D+ef7UJR4j+NpryoB7zstLsZoLvoJ16DBHEFiqbTAHaii2IfsFHT3vcoqjwY015Vrh DZbRU5VOPxi8HEgQqqpX5dyZHezY9Q0Fsj2Cp25Is9ce2nbgC9s0epEqwBAquLdREGUV MhAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=+yIB4TtQhEbL/mvyJX2uAbbwQXERvRXJT6x1cyUEp28=; b=Cx4mPAXnTGxQDaN337jeLXdy+4QUMh1chX4G+irelX0ac9PrmGmAYo5q5ZeDIa50u6 +KBmUTZ7dpCyoQjn+LQ1yZdIsV7U8DoNm20FYUYDicjBl1xAJNsu5lhL4FFjTgMYLJJT le4OMVs+h3IZBZTlTozMXQVDP04t0YhGcmgUDx/BrRhLaCaa9d0IGaohCnH/55LzVOhY Ba0c+jjSGyo8l4JuGMQw9+Ek/RXR5vaWB3BJpOUu+3ZQweua2WvOA8+VywTY55kndnJ/ r8R/hkmKa06QzLAqJ4Az8btrjwgL3LllQn0VPluF519iBbizvNv0a3tYY5ZLl+NbWnFd 2xlg== X-Gm-Message-State: APjAAAX3Q4QfOi+OsFMyYIAcmxvenwAEp40++0tASP5H6Zil+j5Qe0tA 9K2pFHgINWTakjbREvPzvA+84OvJ X-Google-Smtp-Source: APXvYqyDz/3AbEWbzAvt5nwmmzrcx1dfFYP7ZrtH4DDSQOfQc+zLzwiIyxktchUcllZc4PKbOiwxWw== X-Received: by 2002:a05:600c:28d:: with SMTP id 13mr64703wmk.84.1568644936605; Mon, 16 Sep 2019 07:42:16 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id i14sm17024298wra.78.2019.09.16.07.42.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 16 Sep 2019 07:42:15 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 16 Sep 2019 16:41:46 +0200 Message-Id: <1568644929-9124-7-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> References: <1568644929-9124-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32a Subject: [Qemu-devel] [PULL 06/29] exec.c: add a check between constants to see whether we could skip X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Wei Yang Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Wei Yang The maximum level is defined as P_L2_LEVELS and skip is defined with 6 bits, which means if P_L2_LEVELS < (1 << 6), skip never exceeds the boundary. Since this check is between two constants, which leverages compiler to optimize the code based on different configuration. Signed-off-by: Wei Yang Message-Id: <20190321082555.21118-7-richardw.yang@linux.intel.com> Signed-off-by: Paolo Bonzini --- exec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/exec.c b/exec.c index d1969bb..b9511be 100644 --- a/exec.c +++ b/exec.c @@ -324,7 +324,8 @@ static void phys_page_compact(PhysPageEntry *lp, Node *nodes) assert(valid_ptr < P_L2_SIZE); /* Don't compress if it won't fit in the # of bits we have. */ - if (lp->skip + p[valid_ptr].skip >= (1 << 6)) { + if (P_L2_LEVELS >= (1 << 6) && + lp->skip + p[valid_ptr].skip >= (1 << 6)) { return; }