From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A2D50C2BB1D for ; Wed, 18 Mar 2020 00:15:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 6BC5D20738 for ; Wed, 18 Mar 2020 00:15:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="P0EJje5p"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=microsoft.com header.i=@microsoft.com header.b="i2SkoqA/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6BC5D20738 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=microsoft.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IQ42gKiyIhW2jPgkzeBqvLofC8LBh8jRcMgs9vZGSCc=; b=P0EJje5pz525yc Duyd8+bVvEH7EXAbybAiME6eyIhcr81rv02tHuKGNHhk2vYw86uzMFr8d33PcaPXkLpud4Qs+/b/h C6tJrz9x4MvqSJos/XPYaR7IgBzr1jdhz0HdWFCicu2rFwokpA9VcrtNYJlYlSShLatYZLW24Agrs yBIVenqRQU3bUxjJP2H+h7VknsSZwfgaDJ292gRJVVJpOjfj9gqhG0E+L0v8B54h+EQzpZgpwMZZW 6xZA7eBnMsjZvk/2L/xNslT1m26fwLM+IdPW6d9llWBHuQ3rMdemiIUNnAdJDocnJvuIDaGi2fxMX PVDy1KFgnHjX+Uxb+QTQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEMMv-000321-I3; Wed, 18 Mar 2020 00:15:33 +0000 Received: from mail-eopbgr770095.outbound.protection.outlook.com ([40.107.77.95] helo=NAM02-SN1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jEMMs-00031N-C3 for linux-arm-kernel@lists.infradead.org; Wed, 18 Mar 2020 00:15:31 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lR+yVp63qtsbOyn4oC8iHCftYI7XHz5PGlbX8CNchP1a62J4jHbr1iBkbYjXRhg9LnqRI0kKTyD7Dg8+/sFHLuf1gcC7ime31HOISKoD49RKhgoWj6FvgTphhk0EzrlEUKwj0TzE7NDUU8Eh1+5X8pw5r3Ny/r26Fctt5xmLO3ljlSHpe11nJByG1bF0AnJyu9LvNWig+3bxDbAkoNahm8dlwZ0SOHF565S7Dyt8uZr80kH/R8zSPMAmOy7s5iyEo/wj9PcfsCqerg6PmaqR+VCNix2L2hfNqbePj/eqve3Wodbb9pwmCaaysCzRd1gyS3xGVDeDUTOETYLvJHsGgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=auibOauM2Qn9g5DqMGQVNaGcTpC/wJKDvXbpt9ctv4U=; b=V+g0rrq4o0px9JrPE+mIZTcM+wr1DljbUPHGqgci848iQknbD7H0GJmDkqAIluFT75I0KC80U04zJKNotwGPv7GhDw1q3EfRmbRCW+fv4P9mpHxcIxUVapgGSnq3tOnyF9RqqOgKYn40XTM4Qhu29Sh/fUIk+qp5nyzXbQjbyjw3Tv1MM8lxtpP65iO0Yq2gBsfA1Q8QVNGMssBQHihKdwBNO0Gis2ULEsXPH7U+HU4+eGNeBmgh2p4W3yu3EAPwd0FQLogn/3ArVLZkCj5lAfpnDUcpWa3KyQ5eRRk8opU7bDo2ErW/Wbw4QkTIozeUyzQFhiZR1b2oLD7bv/UH/w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=microsoft.com; dmarc=pass action=none header.from=microsoft.com; dkim=pass header.d=microsoft.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=auibOauM2Qn9g5DqMGQVNaGcTpC/wJKDvXbpt9ctv4U=; b=i2SkoqA/81h0idpfH5d1PRo6NzuNdF6zX2bZ2HY/lhXwCPtmXl3fBs93kMThmH2lD3ZsgDROV++QkkNVz5Qq0rfGQ/7pMOyc8FjfK/uItjLfhd9K+IaiMYJcXxE4/VaTykNtz5g16up2VvgzNK/70Gerc1r3jNJIFBOpXcoglcg= Received: from MW2PR2101MB1052.namprd21.prod.outlook.com (2603:10b6:302:a::16) by MW2PR2101MB1082.namprd21.prod.outlook.com (2603:10b6:302:a::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.7; Wed, 18 Mar 2020 00:15:25 +0000 Received: from MW2PR2101MB1052.namprd21.prod.outlook.com ([fe80::71ee:121:71bd:6156]) by MW2PR2101MB1052.namprd21.prod.outlook.com ([fe80::71ee:121:71bd:6156%9]) with mapi id 15.20.2835.003; Wed, 18 Mar 2020 00:15:25 +0000 From: Michael Kelley To: Arnd Bergmann , Marc Zyngier , gregkh Subject: RE: [PATCH v6 04/10] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages Thread-Topic: [PATCH v6 04/10] arm64: hyperv: Add memory alloc/free functions for Hyper-V size pages Thread-Index: AQHV+hZH2sSK6TnWLUqKIqZdhn3BQ6hK4/SAgAACOwCAAACGAIACfgqw Date: Wed, 18 Mar 2020 00:15:25 +0000 Message-ID: References: <1584200119-18594-1-git-send-email-mikelley@microsoft.com> <1584200119-18594-5-git-send-email-mikelley@microsoft.com> <632eb459dbe53a9b69df2a4f030a755b@kernel.org> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Enabled=True; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SiteId=72f988bf-86f1-41af-91ab-2d7cd011db47; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Owner=mikelley@ntdev.microsoft.com; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_SetDate=2020-03-18T00:15:22.5925385Z; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Name=General; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Application=Microsoft Azure Information Protection; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_ActionId=fde423f0-26dd-42cf-838f-65f5cddd7301; MSIP_Label_f42aa342-8706-4288-bd11-ebb85995028c_Extended_MSFT_Method=Automatic authentication-results: spf=none (sender IP is ) smtp.mailfrom=mikelley@microsoft.com; x-originating-ip: [24.22.167.197] x-ms-publictraffictype: Email x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: fbf53d61-1c2b-46bf-0849-08d7cad174d3 x-ms-traffictypediagnostic: MW2PR2101MB1082:|MW2PR2101MB1082:|MW2PR2101MB1082: x-ms-exchange-transport-forked: True x-ld-processed: 72f988bf-86f1-41af-91ab-2d7cd011db47,ExtAddr x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:8273; x-forefront-prvs: 03468CBA43 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(136003)(346002)(376002)(396003)(39860400002)(366004)(199004)(10290500003)(55016002)(478600001)(7696005)(5660300002)(9686003)(110136005)(54906003)(2906002)(7416002)(8990500004)(53546011)(33656002)(52536014)(6506007)(76116006)(71200400001)(186003)(66946007)(66476007)(66446008)(64756008)(66556008)(4326008)(8676002)(316002)(86362001)(81156014)(8936002)(81166006)(26005); DIR:OUT; SFP:1102; SCL:1; SRVR:MW2PR2101MB1082; H:MW2PR2101MB1052.namprd21.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: goHjzolk1403oOapaLy7gmxffuRlCdBEF92SHRi2H3uehK7J3Q0RjubPrpw9hnUC9VTC4Lzqmn3TuscsW7m+0hXCKirsMUByx2zDpiym+UZ+T9Hz+Kn04fRYaZJqLF4HawJ8P5S52Swmdl7aNFAMDdCS34Td8aPjGOy5Jo15VVzmKT4XO6EMNwzoczaw+f/yWBvNoaQfP3eec6VoZrj47wkvsNdPMMhIFP7jbxxj0W4gLg0clheaEjqJ1jUwr1EirAPvJ5c3eIlMpnImuYuHZbu6SSI+mcmpd3X+hJnCzulNz/DPKRQa7Akhvt81jFVq/PlLfSuDJlmCrgG/kHrnHVzeXuxbyxbn7KSPc5jQTQk2DDZqtp2FwKvIMtnKa0E6LM5qM7XdcwuhUuGixNxX7vqn1oA0g3p9dip/pxM2AKIv7ae4ZoDk2l3eHpGb0n4q x-ms-exchange-antispam-messagedata: ZmExURiXqasFD7guooSsdyMOof40Vw/EegP4o3uQqyRUD7Z8UkKZ0HC2UYnCwt7SUwvEShu+q04uFn6AE4g2lS1RLeshn3hC4RtFoWIjltdbIZKnh6JEva0iROQq6OuhGNHdIRuZcJ/n8HuvAsH+Gg== MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: fbf53d61-1c2b-46bf-0849-08d7cad174d3 X-MS-Exchange-CrossTenant-originalarrivaltime: 18 Mar 2020 00:15:25.1158 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: nVPG3c2NE55mUbtqNHoS0CoQgV2RezuE0xNrJ3dNdjW6L2yqiaOCaVuFWozEck9Zq2mrfhRoDQQYb5wROa0Ty9QkZ7CyOPouuJZ20Qskp4M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB1082 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200317_171530_416908_11D37BFB X-CRM114-Status: GOOD ( 18.72 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , linux-arch , "linux-hyperv@vger.kernel.org" , linux-efi , Boqun Feng , Catalin Marinas , Jason Wang , Sunil Muthuswamy , "linux-kernel@vger.kernel.org" , "marcelo.cerri@canonical.com" , "olaf@aepfle.de" , Andy Whitcroft , vkuznets , KY Srinivasan , Will Deacon , Ard Biesheuvel , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Arnd Bergmann Sent: Monday, March 16, 2020 1:33 AM > > On Mon, Mar 16, 2020 at 9:30 AM Marc Zyngier wrote: > > On 2020-03-16 08:22, Arnd Bergmann wrote: > > > On Sat, Mar 14, 2020 at 4:36 PM Michael Kelley > > > wrote: > > >> /* > > >> + * Functions for allocating and freeing memory with size and > > >> + * alignment HV_HYP_PAGE_SIZE. These functions are needed because > > >> + * the guest page size may not be the same as the Hyper-V page > > >> + * size. We depend upon kmalloc() aligning power-of-two size > > >> + * allocations to the allocation size boundary, so that the > > >> + * allocated memory appears to Hyper-V as a page of the size > > >> + * it expects. > > >> + * > > >> + * These functions are used by arm64 specific code as well as > > >> + * arch independent Hyper-V drivers. > > >> + */ > > >> + > > >> +void *hv_alloc_hyperv_page(void) > > >> +{ > > >> + BUILD_BUG_ON(PAGE_SIZE < HV_HYP_PAGE_SIZE); > > >> + return kmalloc(HV_HYP_PAGE_SIZE, GFP_KERNEL); > > >> +} > > >> +EXPORT_SYMBOL_GPL(hv_alloc_hyperv_page); > > > > > > I don't think there is any guarantee that kmalloc() returns > > > page-aligned > > > allocations in general. > > > > I believe that guarantee came with 59bb47985c1db ("mm, sl[aou]b: > > guarantee > > natural alignment for kmalloc(power-of-two)"). > > > > > How about using get_free_pages() to implement this? > > > > This would certainly work, at the expense of a lot of wasted memory when > > PAGE_SIZE isn't 4k. > > I'm sure this is the least of your problems when the guest runs with > a large base page size, you've already wasted most of your memory > otherwise then. > I think there's value in keeping these functions. There are 8 uses in architecture independent code at the moment, which admittedly saves only ~1/2 Mbyte of memory with a 64K page size, but we will have additional uses with more memory savings as we get all of the Hyper-V synthetic drivers to work with 64K page size. Furthermore, there's coming work that will require additional steps to share a page between a guest and the Hyper-V host. These functions are the right place to put the code for the additional sharing steps. Removing them now in favor of a bare kmalloc() and then adding them back doesn't seem worthwhile. Michael _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel