Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp2739465pxb; Mon, 1 Nov 2021 00:22:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx+La5omKrEIGJt+5YOlKYShLX1MnSZ4HHPQ3aFwZTHzlSU4TIx+ukWf4Qmh4LQE2AHLPsn X-Received: by 2002:a92:d752:: with SMTP id e18mr18834098ilq.31.1635751346398; Mon, 01 Nov 2021 00:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635751346; cv=none; d=google.com; s=arc-20160816; b=LOH3kVif3TQlHPzRlAk1mfYcKjtvskqWj2p0vBuxYcVc2Bm54WJFdQ4pF1z4WFSvgX diKimEl2MHEnp3buKO9LpgY50xoWHEc9GQxEI0fM75sO1xQdXVGe/wBAo6yq5BCzICWe HokBQqbtXtgdsVApan86x6DV8EyxEpbfcc2KGfE9X4gLr0kEN3M1bRV/ksEEtymRCTDv dWpHMdNyzTDCQq/vAYlhh6XoosFlowSdqRP1WbqqKE/zrB5xhLgV6Iqdr/Hc8hWXCQRl xpSJ7rjaDptzwPzAzTHAlmfRy0AmCMWSuItpIETpIAfzXWPrcxFRZnVL7q2dBoeGT/KT g5qQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=OiJvobuX3n+EKs/NhnXLnNLW7NKcWLIH/WcTQdqCZ8o=; b=o4vjapVMiJTnnMwX3d4O9+WsPDgh1lLIC//fQve8FSDR20z8GEDM+pWR6HOB6/L/KU 4tVS20EAfxeQj+OF70tOzMgfQJs5E2BX2OThLd2lilVQ69oh930YCfmL/UI4QfoveGng gz/XEzUslcI631qOamY9rjGafjTgWGBp2SrmLprvpAqtavIoaMGRIkncRdmgWDQ8LUPk /hODZhTN49/phi0UZnZSi75UNkee3y/ovB0s8OT88EUDqVy/Ep6dbY3SfOZo5i+ynobW cHAXJVRs0nLzcK7cssclXDzomKCRORIH+wAs3qqmpQlLQtOEkqxZAC/f/9//YM6GYpTk SYYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=I5K8caJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p12si15192965ilg.110.2021.11.01.00.22.15; Mon, 01 Nov 2021 00:22:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=susede1 header.b=I5K8caJm; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=suse.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230508AbhKAHXq (ORCPT + 99 others); Mon, 1 Nov 2021 03:23:46 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:33318 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229882AbhKAHXp (ORCPT ); Mon, 1 Nov 2021 03:23:45 -0400 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CC9F21FD4D; Mon, 1 Nov 2021 07:21:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1635751271; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=OiJvobuX3n+EKs/NhnXLnNLW7NKcWLIH/WcTQdqCZ8o=; b=I5K8caJmT6AxGK8R6Q6oIaoOxGSg79sI95p5WiZq1tU2uqNyf5stcBECg/L7SsHJ6NHsQD 5WuNlPNJjZlUUjzPH0I/uVhA3gyvqVYsqnGiO6nFhKBNyuCACNQrCLbm137wpuSZKvTo18 FVZZN/evzGDicGtdhvHqxbe9+vBGzgI= Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 9853513A6F; Mon, 1 Nov 2021 07:21:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id akM/I2eVf2F/EAAAMHmgww (envelope-from ); Mon, 01 Nov 2021 07:21:11 +0000 Subject: Re: [PATCH v3] xen/balloon: add late_initcall_sync() for initial ballooning done To: Boris Ostrovsky , =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini , stable@vger.kernel.org References: <20211029142049.25198-1-jgross@suse.com> <11956c14-f1f7-70f0-40a6-aad31a264af6@oracle.com> <2365e65f-7431-4bf5-4ced-5e146776b9ac@oracle.com> From: Juergen Gross Message-ID: <0e32534b-c50f-d6ea-2927-dc763939dbcb@suse.com> Date: Mon, 1 Nov 2021 08:21:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.12.0 MIME-Version: 1.0 In-Reply-To: <2365e65f-7431-4bf5-4ced-5e146776b9ac@oracle.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="SatvGOBbXAB4GMvHz0933pF793czZeWDD" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --SatvGOBbXAB4GMvHz0933pF793czZeWDD Content-Type: multipart/mixed; boundary="XMt9OejtjTyGiADg3Sqcf50uQJdI9RM6R"; protected-headers="v1" From: Juergen Gross To: Boris Ostrovsky , =?UTF-8?Q?Marek_Marczykowski-G=c3=b3recki?= Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org, Stefano Stabellini , stable@vger.kernel.org Message-ID: <0e32534b-c50f-d6ea-2927-dc763939dbcb@suse.com> Subject: Re: [PATCH v3] xen/balloon: add late_initcall_sync() for initial ballooning done References: <20211029142049.25198-1-jgross@suse.com> <11956c14-f1f7-70f0-40a6-aad31a264af6@oracle.com> <2365e65f-7431-4bf5-4ced-5e146776b9ac@oracle.com> In-Reply-To: <2365e65f-7431-4bf5-4ced-5e146776b9ac@oracle.com> --XMt9OejtjTyGiADg3Sqcf50uQJdI9RM6R Content-Type: multipart/mixed; boundary="------------C2DAF238F4CCA8207EC03136" Content-Language: en-US This is a multi-part message in MIME format. --------------C2DAF238F4CCA8207EC03136 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: quoted-printable On 30.10.21 01:44, Boris Ostrovsky wrote: >=20 > On 10/29/21 6:18 PM, Marek Marczykowski-G=C3=B3recki wrote: >> On Fri, Oct 29, 2021 at 05:46:18PM -0400, Boris Ostrovsky wrote: >>> On 10/29/21 10:20 AM, Juergen Gross wrote: >>>> --- a/Documentation/ABI/stable/sysfs-devices-system-xen_memory >>>> +++ b/Documentation/ABI/stable/sysfs-devices-system-xen_memory >>>> @@ -84,3 +84,13 @@ Description: >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Control= scrubbing pages before returning them to Xen for=20 >>>> others domains >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 use. Ca= n be set with xen_scrub_pages cmdline >>>> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 paramet= er. Default value controlled with=20 >>>> CONFIG_XEN_SCRUB_PAGES_DEFAULT. >>>> + >>>> +What:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 /sys/devices/system= /xen_memory/xen_memory0/boot_timeout >>>> +Date:=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 November 2021 >>>> +KernelVersion:=C2=A0=C2=A0=C2=A0 5.16 >>>> +Contact:=C2=A0=C2=A0=C2=A0 xen-devel@lists.xenproject.org >>>> +Description: >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 The time (in seconds) to= wait before giving up to boot in case >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 initial ballooning fails= to free enough memory. Applies only >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 when running as HVM or P= VH guest and started with less memory >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 configured than allowed = at max. >>> >>> How is this going to be used? We only need this during boot. >>> >>> >>>> -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 state =3D update_schedul= e(state); >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 balloon_state =3D update= _schedule(balloon_state); >>> >>> Now that balloon_state has whole file scope it can probably be=20 >>> updated inside update_schedule(). >>> >>> >>>> +=C2=A0=C2=A0=C2=A0 while ((credit =3D current_credit()) < 0) { >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (credit !=3D last_cre= dit) { >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = last_changed =3D jiffies; >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 = last_credit =3D credit; >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 } >>>> +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (balloon_state =3D=3D= BP_ECANCELED) { >>> >>> What about other states? We are really waiting for BP_DONE, aren't we= ? >> BP_DONE is set also as an intermediate step: >> >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 balloo= n_state =3D decrease_reservation(n_pages, >> =20 >> GFP_BALLOON); >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 if (ba= lloon_state =3D=3D BP_DONE && n_pages !=3D=20 >> -credit && >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0 n_pages < totalreserve_pages) >> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 balloon_state =3D BP_EAGAIN; >> >> It would be bad to finish waiting in this case. >=20 >=20 > RIght, but if we were to say 'if (balloon_state !=3D BP_DONE)' the wors= t=20 > that can happen is that we will continue on to the next iteration=20 > without warning and/or panicing. Of course, there is a chance thaton th= e=20 > next iteration the same thing will happen but I think chances of hittin= g=20 > this race every time are infinitely low. We can also check for=20 > current_credit() again. >=20 >=20 > The question is whether we do want to continue waiting if we are in=20 > BP_AGAIN. I don't think BP_WAIT is possible in this case although this = > may change in the future and we will forget to update this code. BP_EAGAIN should not stop waiting, as it might be intermediate in case some caches or buffers are freed. Juergen --------------C2DAF238F4CCA8207EC03136 Content-Type: application/pgp-keys; name="OpenPGP_0xB0DE9DD628BF132F.asc" Content-Transfer-Encoding: quoted-printable Content-Description: OpenPGP public key Content-Disposition: attachment; filename="OpenPGP_0xB0DE9DD628BF132F.asc" -----BEGIN PGP PUBLIC KEY BLOCK----- xsBNBFOMcBYBCACgGjqjoGvbEouQZw/ToiBg9W98AlM2QHV+iNHsEs7kxWhKMjrioyspZKOBy= cWx w3ie3j9uvg9EOB3aN4xiTv4qbnGiTr3oJhkB1gsb6ToJQZ8uxGq2kaV2KL9650I1SJvedYm8O= f8Z d621lSmoKOwlNClALZNew72NjJLEzTalU1OdT7/i1TXkH09XSSI8mEQ/ouNcMvIJNwQpd369y= 9bf IhWUiVXEK7MlRgUG6MvIj6Y3Am/BBLUVbDa4+gmzDC9ezlZkTZG2t14zWPvxXP3FAp2pkW0xq= G7/ 377qptDmrk42GlSKN4z76ELnLxussxc7I2hx18NUcbP8+uty4bMxABEBAAHNHEp1ZXJnZW4gR= 3Jv c3MgPGpnQHBmdXBmLm5ldD7CwHkEEwECACMFAlOMcBYCGwMHCwkIBwMCAQYVCAIJCgsEFgIDA= QIe AQIXgAAKCRCw3p3WKL8TL0KdB/93FcIZ3GCNwFU0u3EjNbNjmXBKDY4FUGNQH2lvWAUy+dnyT= hpw dtF/jQ6j9Rw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ha96vm4P/L+bQpJwrZ/dneZcmEw= Tbe 8YFsw2V/Buv6Z4Mysln3nQK5ZadD534CF7TDVft7fC4tU4PONxF5D+/tvgkPfDAfF77zy2AH1= vJz Q1fOU8lYFpZXTXIHb+559UqvIB8AdgR3SAJGHHt4RKA0F7f5ipYBBrC6cyXJyyoprT10EMvU8= VGi wXvTyJz3fjoYsdFzpWPlJEBRMedCot60g5dmbdrZ5DWClAr0yau47zpWj3enf1tLWaqcsuylW= svi uGjKGw7KHQd3bxALOknAp4dN3QwBYCKuZ7AddY9yjynVaD5X7nF9nO5BjR/i1DG86lem3iBDX= zXs ZDn8R38=3D =3D2wuH -----END PGP PUBLIC KEY BLOCK----- --------------C2DAF238F4CCA8207EC03136-- --XMt9OejtjTyGiADg3Sqcf50uQJdI9RM6R-- --SatvGOBbXAB4GMvHz0933pF793czZeWDD Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsB5BAABCAAjFiEEhRJncuj2BJSl0Jf3sN6d1ii/Ey8FAmF/lWYFAwAAAAAACgkQsN6d1ii/Ey80 KAf/Qqdw1mA/ijbb+odtKZ9Vua+VXes2bJWyzjxtQ/zKSRUvqcJ7qttbzmLt2A6ar2pscUiUGG5H CVFIfzxKE3qXV7IlkEtyQ7bRFpL0Y7YjH5HnhM4mr6bttQZX6qwQDvGuNwLwkTP6bD4TVmN/wNoD U1sjdad8E2Ay8a7+rbuVdii7lJ5RgrzXBnKVJDqqztYiWh/WgjC0r2kiCP46ZqVtimwzr6T7cB+5 f/OxmURztozz9NrXxmM7ST2XvAi4CBerYJAtr+KQvJg+3BD24MLRLg2JHX8ZIVrt2U7vjlKH1CAW 2c2ZsVpDv5xTgO4Y9SjpUqBsXz+x+K8GHgnadzjSfg== =8Vp5 -----END PGP SIGNATURE----- --SatvGOBbXAB4GMvHz0933pF793czZeWDD--