Received: by 2002:a05:6a10:83d0:0:0:0:0 with SMTP id o16csp47344pxh; Thu, 7 Apr 2022 13:34:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzW8XaNOTjT5Iz+0TvGzC4LtH3CS/6QERMnhMeUzePO7shktlTqqBDxxiBk687+XpQkdxd/ X-Received: by 2002:a05:6a02:197:b0:382:a4b0:b9a8 with SMTP id bj23-20020a056a02019700b00382a4b0b9a8mr12585783pgb.325.1649363641417; Thu, 07 Apr 2022 13:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1649363641; cv=none; d=google.com; s=arc-20160816; b=vA5ee/WXYxAG9E62JZTk0VMTS7lHMb9vNybhCqnz3IgsLFPEUPMIDVdk5i1WmhEIkU Nddwt1sU+fVcXRqXfxVR1N4R/yvEXPRmRabXqqY3mTjp9wYH7fajp7Xj0YJBy66c5/vq hW2rdG54jae3+LV4AbH1f8cHZXVWg5SHA/HcIRQcNCAnnv6mBs82Dw20AaufoccKvbdV Ew5ep+Yq8BrCry69ICIEB0xkNTLzARt2Ak6uAfkRXee0tsSCmNn5CCo5FquObWCQPMGX BbabdGsWWaDfsS/+lW8Qf/cauzpu1tx7EmeoWDg1AXQ+2RA3Kuln/k4o0Cf2iDx+XnYn OQnA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:subject :organization:from:references:cc:to:content-language:user-agent :mime-version:date:message-id:dkim-signature; bh=6Ak2L++rWGA7iZB3bqmGGUjd7xVRHy3vUvtqw/fn7ZM=; b=Vq62lTw/sQBpq9JL7YJ9XABiQsjbZmgI10FLXCX7YZGkimj9smYuO/m44lpF8e2wEX B0EUo5zA03LpDxt0nFYS2TEa49gppnJ4mvXCRuCVL43kc4w3JSx8MDaj742m5a24ry2/ NiT1GCL/ewqhaLdF4B5bnwIq+RPUHn9ldOkDgdsQktmOfUW5GQfYH/jn+zObHm8IwLFK t1zjFQkpueMC4FWvSTO42DbKWRsPjmjNNj/rP+UTKdQQhmmJEeZpo1cy0Q2Zwig394Rq SbRKm2zTqY0q4AvZc2xU3Q0xzg9/p6dYuPEjuHp3AEhB24MgjM86NxqeDIm2i7GYnm9M /Glg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jL8rHmXi; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id q4-20020a63cc44000000b003816043ee48si19112196pgi.61.2022.04.07.13.34.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Apr 2022 13:34:01 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jL8rHmXi; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 0C14E21CC50; Thu, 7 Apr 2022 12:46:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242934AbiDGIZO (ORCPT + 99 others); Thu, 7 Apr 2022 04:25:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231650AbiDGIZN (ORCPT ); Thu, 7 Apr 2022 04:25:13 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 17C89101F8 for ; Thu, 7 Apr 2022 01:23:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1649319792; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6Ak2L++rWGA7iZB3bqmGGUjd7xVRHy3vUvtqw/fn7ZM=; b=jL8rHmXi9ta4KzWQQyQYRmb3eRNFJzsyzpCxUy2IaWCDTmJYGO1v3R0TXGnVzAkrESwvEt u0GsPNmCrheOYBdOjgIIOGTAkcrfDODUHmBQrdYvrPBg/q+uvMEWZGfjJ7NVzBIHg2d6bz CrtoMx3yRjJJSbLE3iVyiz+3w/e/Wcc= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-38-zTkK1J7yO4e4MR8O9dveWQ-1; Thu, 07 Apr 2022 04:23:11 -0400 X-MC-Unique: zTkK1J7yO4e4MR8O9dveWQ-1 Received: by mail-wm1-f70.google.com with SMTP id m3-20020a05600c3b0300b0038e74402cb6so2621005wms.8 for ; Thu, 07 Apr 2022 01:23:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent :content-language:to:cc:references:from:organization:subject :in-reply-to:content-transfer-encoding; bh=6Ak2L++rWGA7iZB3bqmGGUjd7xVRHy3vUvtqw/fn7ZM=; b=EmCDLEG0q91PX2XwlQaA8z66z2bz3LIC7BmTOWBnqsoufCk2j8NaXjIls2u38XiZTu w/Lcr2qoCb3464x6xHeM7fVJgQwi3vqzB9RxhRhblz28iorN5R0LRRLWXJb0vnY66MC2 Eq0GR5v5dIwUmcewKIQqb545LPLdyZgR6sTSaTG88bzHxwb1meU9EoEFR/WNcgbdttOr 0aUqXj82pwgDuXAh0K4qM0sdjy725pgTd7Oj295/9qgrCgBGwjDAeWRSWb07q43lVggp RPHaanNyC5pc+UmuNKld4FxyTs4927VFWjfGK8A2b7RZyYjTlwPZIDLj9nb+vcmVJfIq taSA== X-Gm-Message-State: AOAM532uxJ1wyn8LlMzydvk+m9aFsjn+WTIDq1NcEfcqQFwjJiMWyrVG IHNJNUbEIks0037Ei8/Ce0QHtIxEgr1aAi/lr5rtpsE96tyPstYlVV+PsHNjWvbuVgOnWKvg9La y2HskxY7/6nrz+Cio08c7VPbh X-Received: by 2002:adf:8046:0:b0:205:db94:4766 with SMTP id 64-20020adf8046000000b00205db944766mr9967284wrk.565.1649319789894; Thu, 07 Apr 2022 01:23:09 -0700 (PDT) X-Received: by 2002:adf:8046:0:b0:205:db94:4766 with SMTP id 64-20020adf8046000000b00205db944766mr9967251wrk.565.1649319789519; Thu, 07 Apr 2022 01:23:09 -0700 (PDT) Received: from ?IPV6:2a09:80c0:192:0:20af:34be:985b:b6c8? ([2a09:80c0:192:0:20af:34be:985b:b6c8]) by smtp.gmail.com with ESMTPSA id k11-20020a5d6d4b000000b0020599079f68sm16415621wri.106.2022.04.07.01.23.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 Apr 2022 01:23:09 -0700 (PDT) Message-ID: <89ad978d-e95e-d3ea-5c8f-acf4b28f992c@redhat.com> Date: Thu, 7 Apr 2022 10:23:08 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.6.2 Content-Language: en-US To: Juergen Gross , xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org Cc: Boris Ostrovsky , Stefano Stabellini , stable@vger.kernel.org, =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= , Wei Yang , Michal Hocko References: <20220406133229.15979-1-jgross@suse.com> From: David Hildenbrand Organization: Red Hat Subject: Re: [PATCH] xen/balloon: fix page onlining when populating new zone In-Reply-To: <20220406133229.15979-1-jgross@suse.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 06.04.22 15:32, Juergen Gross wrote: > When onlining a new memory page in a guest the Xen balloon driver is > adding it to the ballooned pages instead making it available to be > used immediately. This is meant to enable to add a new upper memory > limit to a guest via hotplugging memory, without having to assign the > new memory in one go. > > In case the upper memory limit will be raised above 4G, the new memory > will populate the ZONE_NORMAL memory zone, which wasn't populated > before. The newly populated zone won't be added to the list of zones > looked at by the page allocator though, as only zones with available > memory are being added, and the memory isn't yet available as it is > ballooned out. I think we just recently discussed these corner cases on the -mm list. The issue is having effectively populated zones without manages pages because everything is inflated in a balloon. That can theoretically also happen when managing to fully inflate the balloon in one zone and then, somehow, the zones get rebuilt. build_zonerefs_node() documents "Add all populated zones of a node to the zonelist" but checks for managed zones, which is wrong. See https://lkml.kernel.org/r/20220201070044.zbm3obsoimhz3xd3@master > > This will result in the new memory being assigned to the guest, but > without the allocator being able to use it. > > When running as a PV guest the situation is even worse: when having > been started with less memory than allowed, and the upper limit being > lower than 4G, ballooning up will have the same effect as hotplugging > new memory. This is due to the usage of the zone device functionality > since commit 9e2369c06c8a ("xen: add helpers to allocate unpopulated > memory") for creating mappings of other guest's pages, which as a side > effect is being used for PV guest ballooning, too. > > Fix this by checking in xen_online_page() whether the new memory page > will be the first in a new zone. If this is the case, add another page > to the balloon and use the first memory page of the new chunk as a > replacement for this now ballooned out page. This will result in the > newly populated zone containing one page being available for the page > allocator, which in turn will lead to the zone being added to the > allocator. This somehow feels like a hack for something that should be handled in the core instead :/ -- Thanks, David / dhildenb