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=-7.3 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 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 2CB83C433B4 for ; Thu, 8 Apr 2021 14:13:03 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (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 BF69E600D1 for ; Thu, 8 Apr 2021 14:13:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org BF69E600D1 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=suse.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from list by lists.xenproject.org with outflank-mailman.107364.205249 (Exim 4.92) (envelope-from ) id 1lUVOs-0008KF-1d; Thu, 08 Apr 2021 14:12:50 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 107364.205249; Thu, 08 Apr 2021 14:12:50 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUVOr-0008K8-Ur; Thu, 08 Apr 2021 14:12:49 +0000 Received: by outflank-mailman (input) for mailman id 107364; Thu, 08 Apr 2021 14:12:49 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lUVOr-0008K3-MI for xen-devel@lists.xenproject.org; Thu, 08 Apr 2021 14:12:49 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id dab48eb7-7b5b-4b6b-a8fa-11f133a1b708; Thu, 08 Apr 2021 14:12:48 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id A38BCB032; Thu, 8 Apr 2021 14:12:47 +0000 (UTC) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: dab48eb7-7b5b-4b6b-a8fa-11f133a1b708 X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1617891167; h=from:from:reply-to: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=7aY8XBU2I/xhPL/+cky9pI9nmJtbbXW1juxdmt5fDgQ=; b=dD7jJEJBH6S/5bCD6T4vfcSQLxqil7WO5gG8vrGBdkciiAAjLhzNiDyty1nc+/dhfrvBp5 qeoUqfa5dWj9qBw3fYjfmcU5OKzurd8XDlCSbLt9qfws30+d9DWyijtTs0drKX2Zhp5AhQ 9ZSR8Pl3fXF6eEJy8PXjEwbHBWCAJAE= Subject: Re: [PATCH 00/11] assorted replacement of x[mz]alloc_bytes() To: Andrew Cooper Cc: George Dunlap , Ian Jackson , Julien Grall , Stefano Stabellini , Wei Liu , =?UTF-8?Q?Roger_Pau_Monn=c3=a9?= , "xen-devel@lists.xenproject.org" References: From: Jan Beulich Message-ID: <8c9177fa-9909-b693-e4ee-efdfcfa51273@suse.com> Date: Thu, 8 Apr 2021 16:12:47 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit On 08.04.2021 14:57, Andrew Cooper wrote: > On 08/04/2021 13:13, Jan Beulich wrote: >> In the long run I think we want to do away with these type-unsafe >> interfaces, the more that they also request (typically) excess >> alignment. This series of entirely independent patches is >> eliminating the instances where it's relatively clear that they're >> not just "blob" allocations. >> >> >> 03: x86/MCE: avoid effectively open-coding xmalloc_array() >> 04: x86/HVM: avoid effectively open-coding xmalloc_array() >> 05: x86/oprofile: avoid effectively open-coding xmalloc_array() >> 06: x86/IRQ: avoid over-alignment in alloc_pirq_struct() >> 07: EFI/runtime: avoid effectively open-coding xmalloc_array() >> 08: hypfs: avoid effectively open-coding xzalloc_array() >> 10: video/lfb: avoid effectively open-coding xzalloc_array() > > The flex conversions are fine, but I am unconvinced by argument for > interchanging array() and bytes(). > > The cacheline size is 64 bytes, and the minimum allocation size is 16, > plus a bhdr overhead of 32 bytes, so you're already at most of a > cacheline for a nominally-zero sized allocation. But you're aware that the alignment x[mz]alloc_bytes() forces is 128 bytes? Plus, while sizeof(struct bhdr) is indeed 32, the overhead on allocated blocks is #define BHDR_OVERHEAD (sizeof(struct bhdr) - MIN_BLOCK_SIZE) i.e. 16 (i.e. the other half of the 32 is already the minimum block size of 16 that you also mention). IOW a cacheline sized block would yield 48 bytes of usable space. Specifically a meaningful change in the PV case from what patch 06 does, where we only need 40 bytes. > There can however be a severe penalty from cacheline sharing, which is > why the bytes() form does have a minimum alignment.  There is one > xmalloc heap shared across the entire system, so you've got no idea what > might be sharing the same cache line for sub-line allocations. This would call for distinguishing short-lived allocations (and ones to be used mainly from a single CPU) from long-lived ones having system wide use. I.e. a request to gain further allocation function flavors, when already the introduction of the one new xv[mz]alloc() has caused long-winded discussions with (so far) no real outcome. > We should not support sub-line allocations IMO.  The savings is a > handful of bytes at best, and some horrible performance cliffs to > avoid.  People running virtualisation are not going to be ram > constrained to the order of a few bytes. > > For small allocations which don't require specific alignment, then > putting bhdr and the allocation in the same line is fine (if we don't do > this already), but we shouldn't be in the position of having two bhdr's > in the same cache line, even if there are plenty of single-byte > allocations in the theoretical worst case. That's a request to tweak allocator internals then, not an argument against the conversions done here. Jan