Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp647460imu; Fri, 7 Dec 2018 06:51:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/X2/jzinJKMFd4PRQRGifLY2LwuQ2Du6yjf6tc/GvbSvOQZCaU6wK9S5eqE/B1eWgb1ZZAA X-Received: by 2002:a17:902:6848:: with SMTP id f8mr2345273pln.300.1544194267562; Fri, 07 Dec 2018 06:51:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544194267; cv=none; d=google.com; s=arc-20160816; b=SPUp3wdzKxomdmCNEY1264+CvxeLlQw1qpXvR3KomvRrDP9ASPjZMxoZWgWomkTyjL /wGV1FWWtayK058KzJKx3HUJ9r6hj4rIjdwOA4cXg9Y6eNmHsCI6ABubCFkmgo7WZB2I ioBjFofjteyN/grbiDD+SvEsxq0gnTgcAb38q2lKllxV8+HhRPZ8K0WSTVGJNIxPWENy QEFcU56+7ZqMYP5bQBdxr/3PUNQybDsYsvZ30M8sPLg5wkFJyTvrzIRgzpxBF4zbazky gcRrUAF3C/7B8pHzevfPxfQkEWYVnUsQs4DgRmRuFCM1MuW5Jf6CSokbeAMEWpvEgBIn doWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=ih67w6iRDo2IoIdUmNkNmzCGOOvc6rRfeDTwXB4jAx4=; b=i16L5Su8kWZ8WHuQHZpGJ+B+7RLVFgyBfa27rOs+giGpqEsj+sVvXka4TU+5KZYjjq cqDFieg1nuYDherhsSZWUpYZ8qp/7jLDPvLRROlktXnGJyKhFEW0PjB3wf4WZFBtHGnS UibuZ7MkHYQBinRDUGGdDvcEQhrdAWiMKc4qGAMJFbHRCnGvrYU6HDf1FW3oL13NZLoj f4mGrsKlXx+5Ybcn0V6vECcSlikBW4C7qNAOW+dPMexCK1bDHWN4pxD4z7jclbY+ztAh t1x8qPPYfwxua2o6QpHlweN5VY9EX8yXOXefsY6PUE9M3ssapXBsyrc5wBeuUWGBCcbm wgGg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x6si2982641pln.425.2018.12.07.06.50.50; Fri, 07 Dec 2018 06:51:07 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726083AbeLGOtd (ORCPT + 99 others); Fri, 7 Dec 2018 09:49:33 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:46528 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbeLGOtc (ORCPT ); Fri, 7 Dec 2018 09:49:32 -0500 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 CFE2315AB; Fri, 7 Dec 2018 06:49:31 -0800 (PST) Received: from [10.1.196.55] (e112269-lin.cambridge.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BF0AB3F575; Fri, 7 Dec 2018 06:49:30 -0800 (PST) Subject: Re: [PATCH] kvm/arm: return 0 when the number of objects is not less than min To: Andrew Jones , Peng Hao Cc: marc.zyngier@arm.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu References: <1543972551-60951-1-git-send-email-peng.hao2@zte.com.cn> <20181205083236.5tzhnxfhi4h4nknn@kamzik.brq.redhat.com> From: Steven Price Message-ID: <4c32963e-0dc7-1867-aa76-7314334315c4@arm.com> Date: Fri, 7 Dec 2018 14:49:29 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.3.0 MIME-Version: 1.0 In-Reply-To: <20181205083236.5tzhnxfhi4h4nknn@kamzik.brq.redhat.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/12/2018 08:32, Andrew Jones wrote: > On Wed, Dec 05, 2018 at 09:15:51AM +0800, Peng Hao wrote: >> Return 0 when there is enough kvm_mmu_memory_cache object. >> >> Signed-off-by: Peng Hao >> --- >> virt/kvm/arm/mmu.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c >> index ed162a6..fcda0ce 100644 >> --- a/virt/kvm/arm/mmu.c >> +++ b/virt/kvm/arm/mmu.c >> @@ -127,7 +127,7 @@ static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, >> while (cache->nobjs < max) { >> page = (void *)__get_free_page(PGALLOC_GFP); >> if (!page) >> - return -ENOMEM; >> + return cache->nobjs >= min ? 0 : -ENOMEM; > > This condition will never be true here, as the exact same condition is > already checked above, and if it had been true, then we wouldn't be here. The condition can be true if the loop is executed at least once. This change would appear to allow the call to succeed in the case where the cache can be topped up to at least "min", but not as far as "max". It would be good to know in what situation this has actually been hit though (and indeed whether this has actually been seen) - the system must be very short on memory to need this, and I'd be surprised if further failures didn't happen later on. > What problem are you attempting to solve? > >> cache->objects[cache->nobjs++] = page; >> } >> return 0; >> -- >> 1.8.3.1 >> >> _______________________________________________ >> kvmarm mailing list >> kvmarm@lists.cs.columbia.edu >> https://lists.cs.columbia.edu/mailman/listinfo/kvmarm > _______________________________________________ > kvmarm mailing list > kvmarm@lists.cs.columbia.edu > https://lists.cs.columbia.edu/mailman/listinfo/kvmarm >