Received: by 10.213.65.68 with SMTP id h4csp559552imn; Tue, 27 Mar 2018 04:46:19 -0700 (PDT) X-Google-Smtp-Source: AG47ELvf3493X095IwZYFojSuQoZKuejH1YaFESP2ABhrgPUvjQeP6EeoS8Z4v7OBUV3Ya6WMZZt X-Received: by 10.99.96.193 with SMTP id u184mr31866568pgb.103.1522151179605; Tue, 27 Mar 2018 04:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522151179; cv=none; d=google.com; s=arc-20160816; b=j8m7z+y29gYfI8YI3vkwludp6epFCvx/XjBYu1LEYTmMTqPRq2z+ddYfGDEF4fIbtI LUw864xhBDRPEVWdbynHF/xt/P86NfOyr82NxvNZbivKvGJLIkWoPd/Q4caEX+wJFGau uYmprB27pOcbIB2A/7UkH4z0pAKAoQ7kFIWWQg9sQKkW+HkYd8FP3lBw1t37viHPJ1in 3R3IravGRzW9NwUfj6+4MNd0ug+PK7oLBpHI2RZSwKzzvNTPj+d4j0HfUMq9T58KOWhA 0H0WP6zaeQhr10flM7RgW+etEeVE7cFANhg9aD9EDdpWAo7pgEgeeQbvBC179Yr6wYQ5 8OUg== 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:arc-authentication-results; bh=zVEF546kkfdysQpGmIQ2USGsHK8+Ee3iHyHRxJ16V6k=; b=Subx5XkpxtrAfiGQiKLjPKA6Iaw/QFvOTVLkaGc2/5X45QF4hljQfjFgIzCIgw+jL3 Dwp/+N8UxtnSjqiT/eWEmbfurDoo9807BxUHcLR53CcV5SGg2zerGkSKkPxVq/CJxcBD weIzQ7zUAif0Oc+YMbGW1YmCtQm8NIxGIQB3umFHlVSZMUVJ/a37zNJANtVTDCN+3Ym3 Bp7Z+ALc3t8B9+INnW5dTbjBUsqOtfwWJaXQR5vUMrPnpXzxZWLuBuDpPr2TwzOSSUYv +2j4yXra8iQX5Xsl38h3pnWEUxt/NxVRm4ed+GsQ0BwVrHCeig71C7KYicwtiCU6m5Za 6PPw== 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 u11-v6si1027154pls.735.2018.03.27.04.46.04; Tue, 27 Mar 2018 04:46:19 -0700 (PDT) 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 S1752004AbeC0Ln3 (ORCPT + 99 others); Tue, 27 Mar 2018 07:43:29 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:30932 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751063AbeC0Ln2 (ORCPT ); Tue, 27 Mar 2018 07:43:28 -0400 Received: from LHREML713-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 4A70DB180A804; Tue, 27 Mar 2018 12:43:24 +0100 (IST) Received: from [10.122.225.51] (10.122.225.51) by smtpsuk.huawei.com (10.201.108.36) with Microsoft SMTP Server (TLS) id 14.3.382.0; Tue, 27 Mar 2018 12:43:21 +0100 Subject: Re: [PATCH 3/6] Protectable Memory To: Matthew Wilcox CC: , , , , , , , , , References: <20180327015524.14318-1-igor.stoppa@huawei.com> <20180327015524.14318-4-igor.stoppa@huawei.com> <20180327023110.GD10054@bombadil.infradead.org> From: Igor Stoppa Message-ID: <4bafdb91-307b-ff4c-5432-cf5a39dfbb8b@huawei.com> Date: Tue, 27 Mar 2018 14:43:19 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: <20180327023110.GD10054@bombadil.infradead.org> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.122.225.51] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 27/03/18 05:31, Matthew Wilcox wrote: > On Tue, Mar 27, 2018 at 04:55:21AM +0300, Igor Stoppa wrote: >> +static inline void *pmalloc_array_align(struct pmalloc_pool *pool, >> + size_t n, size_t size, >> + short int align_order) >> +{ > > You're missing: > > if (size != 0 && n > SIZE_MAX / size) > return NULL; ACK >> + return pmalloc_align(pool, n * size, align_order); >> +} > >> +static inline void *pcalloc_align(struct pmalloc_pool *pool, size_t n, >> + size_t size, short int align_order) >> +{ >> + return pzalloc_align(pool, n * size, align_order); >> +} > > Ditto. ok >> +static inline void *pcalloc(struct pmalloc_pool *pool, size_t n, >> + size_t size) >> +{ >> + return pzalloc_align(pool, n * size, PMALLOC_ALIGN_DEFAULT); >> +} > > If you make this one: > > return pcalloc_align(pool, n, size, PMALLOC_ALIGN_DEFAULT) ok > then you don't need the check in this function. > > Also, do we really need 'align' as a parameter to the allocator functions > rather than to the pool? I actually wrote it first without, but then I wondered how to deal if one needs to allocate both small fry structures and then something larger that is page aligned. However it's just speculation, I do not have any real example. > I'd just reuse ARCH_KMALLOC_MINALIGN from slab.h as the alignment, and > then add the special alignment options when we have a real user for them. ok -- thanks, igor