Received: by 10.223.176.5 with SMTP id f5csp696265wra; Sat, 3 Feb 2018 08:17:21 -0800 (PST) X-Google-Smtp-Source: AH8x226LRJe+81/fd0wVQ4WXx3V7Tt5ViYhKbvcdPWdkL9rM4bW/A9bdcw4V+l6Gk8KSg3xGOKfV X-Received: by 2002:a17:902:8304:: with SMTP id bd4-v6mr23052711plb.123.1517674641485; Sat, 03 Feb 2018 08:17:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517674641; cv=none; d=google.com; s=arc-20160816; b=KiDJUwtKdIGDq6v93dbiF0F4CJnG3k/8jF8zJyPYBvQmsfYJqKNWNVczq+E7ynvdwM ZT4tDrfmVLIr9CNdjrxHyBSHp1g1UBnoe3NhaQaF6qHlKFKgxxsRHqfucGoGLhIVnhPQ KansnvbGJJRCZ67BH20lHB2QSbnmDaU0o2mlfwWqSnM4IwS+JQIvxACH7C6eCLY6SWLq vPF3OLR1hf7/0ScKK7gVb0NX4MfsXEYR21/28oa2uj94URU5HIAPL9hxzMGYvP4F7qxn +wMreh7eWsN24BRNUhnb4mpeLwwOR0hePQbQ84KODV44/m68ySd86PChpi5bH4U5uBvW qLiQ== 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=h7opQsocjQ7g9BoiHyxfpa+eBJT4UhnU2JxOaCXJT48=; b=ZyNdRMuDuJhdYAhdDqm4EFCcX5cOecalxfNjPbFVcrIVnFjDn1p88SexUCr/XYNHiz zjD0wivxASdHqT8CSUhxgP74DOzykX6h3+tyNX11blj/5MT7OK5+MJrOXzvwch3VqJBi FSnRNAHeIOG9TCayuh8ZDGN+2Ds8SQ1/B6gXC+8r+9qPdGMMWdO/gS8us2zb3lVqiDzK SfULXGyO5SvYJCr/4nLjoHTZWtk3nKu1ZSu7xGVCPLiUBQ0qWTUkV5hRLky4XZkyiUcz PUJNmHh5wgpHrlwBRV1gzLtLYW63PJYfiS5DO0ezYuLGJUwnwDQdTbWG8PF6QYCNhjds EW+A== 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 e15-v6si2145205pli.828.2018.02.03.08.17.06; Sat, 03 Feb 2018 08:17:21 -0800 (PST) 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 S1752604AbeBCQO2 (ORCPT + 99 others); Sat, 3 Feb 2018 11:14:28 -0500 Received: from lhrrgout.huawei.com ([194.213.3.17]:24956 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751644AbeBCQOU (ORCPT ); Sat, 3 Feb 2018 11:14:20 -0500 Received: from LHREML714-CAH.china.huawei.com (unknown [172.18.7.107]) by Forcepoint Email with ESMTP id 39CE9FF0454D9; Sat, 3 Feb 2018 16:14:06 +0000 (GMT) Received: from [10.122.225.51] (10.122.225.51) by smtpsuk.huawei.com (10.201.108.37) with Microsoft SMTP Server (TLS) id 14.3.361.1; Sat, 3 Feb 2018 16:14:05 +0000 Subject: Re: [PATCH 3/6] struct page: add field for vm_struct To: Christopher Lameter CC: , , , , , , , , , References: <20180130151446.24698-1-igor.stoppa@huawei.com> <20180130151446.24698-4-igor.stoppa@huawei.com> <48fde114-d063-cfbf-e1b6-262411fcd963@huawei.com> From: Igor Stoppa Message-ID: Date: Sat, 3 Feb 2018 18:13:58 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: 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 02/02/18 20:43, Christopher Lameter wrote: > On Thu, 1 Feb 2018, Igor Stoppa wrote: > >>> Would it not be better to use compound page allocations here? [...] > Ok its compound_head(). See also the use in the SLAB and SLUB allocator. > >> During hardened user copy permission check, I need to confirm if the >> memory range that would be exposed to userspace is a legitimate >> sub-range of a pmalloc allocation. > > If you save the size in the head page struct then you could do that pretty > fast. Ok, now I get what you mean. But it doesn't seem to fit the intended use case, for other reasons (maybe the same, from 2 different POV): - compound pages are aggregates of regular pages, in numbers that are powers of 2, while the amount of pages to allocate is not known upfront. One *could* give a hint to pmalloc about how many pages to allocate every time there is a need to grow the pool. Iow it would be the size of a chunk. But I'm afraid the granularity would still be pretty low, so maybe it would be 2-4 times less. - the property of the compound page will affect the property of all the pages in the compound, so when one is write protected, it can generate a lot of wasted memory, if there is too much slack (because of the order) With vmalloc, I can allocate any number of pages, minimizing the waste. Finally, there was a discussion about optimization: http://www.openwall.com/lists/kernel-hardening/2017/08/07/2 The patch I sent does indeed take advantage of the new information, not just for pmalloc use. I have not measured if/where/what there is gain, but it does look like the extra info can be exploited also elsewhere. -- igor