Received: by 10.213.65.68 with SMTP id h4csp1088193imn; Wed, 14 Mar 2018 09:15:01 -0700 (PDT) X-Google-Smtp-Source: AG47ELuX+MEncklHr0VbU8eJNY0NPthn3RKWRHzrKFES2jTu8n2nTM+ooTTV4IW67w6eYmllnwot X-Received: by 2002:a17:902:367:: with SMTP id 94-v6mr4716568pld.140.1521044101026; Wed, 14 Mar 2018 09:15:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521044100; cv=none; d=google.com; s=arc-20160816; b=wK9IORSwYvTwdxgjDlaKpEB6bVKsWGZ0bhy0kfN4xHrPUHW2eVdU2CaAfwTDyXemgU 4CcRPS1rLsCenDV0N1WUOfaOsd7d3y/1f1u3zKAz8b07NmoDh79erFHuuGoy4UrjyIE4 WJRnE0V4yHYPrDgykVPxgaBpcl4kVKqdDIczUaShZzwhNcfJfSIS7T7pQXDMRlOL90di fXQbUz74v9N3KhFtvj92u9wv7ow+BOVd6MgTy8U1VQMgYTK1DjuLsIDoJoli0pk0Y2ZI qemU1CntRmf4SxJHYiX0QQhQ2GFqSvTmD+ToQn4H8zMOJe/nTRIWu34XiiUEqmhAVGNx ev7A== 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=zmyx8qHAsyzN34GJnI1jbVzmiFkMaGU5HgMd2q+5UVI=; b=mnOcBo1yQewNylw52Yv6dgPa8Lqgm9KnNqafbip22pR99UpPVcsOsns/Ijk+MBwq18 I+zn7WvAD2RIqDwDQ7QfmeGSVYQRY3cTmhoJb1BhtT5bUERSOV+VPyMqOweG7niM2xr1 wsS5LuqzJq/JaWb56B9/3q9uQLICTiMvM/mQ76e+CYRMYJYLhaj8/r+ytKfZkp9Vt8c3 mhPP+sN5ioCGJupjEfT1x6nYF+lhV2+mvXxkZ/FjskWdJz2Kvdn6OcsoasMcjLiclPV9 FP5kT2GTe20st+OLKRpJiHJ3NrY6Vy8b2RlKSYDt+xe9m6hpdKCPPeP92e7bazK8391D N7bg== 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 f9-v6si2140490pln.542.2018.03.14.09.14.47; Wed, 14 Mar 2018 09:15:00 -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 S1751532AbeCNQMN (ORCPT + 99 others); Wed, 14 Mar 2018 12:12:13 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:29405 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750862AbeCNQML (ORCPT ); Wed, 14 Mar 2018 12:12:11 -0400 Received: from LHREML711-CAH.china.huawei.com (unknown [172.18.7.108]) by Forcepoint Email with ESMTP id CA3042C87FE85; Wed, 14 Mar 2018 16:12:07 +0000 (GMT) Received: from [10.122.225.51] (10.122.225.51) by smtpsuk.huawei.com (10.201.108.34) with Microsoft SMTP Server (TLS) id 14.3.382.0; Wed, 14 Mar 2018 16:12:06 +0000 Subject: Re: [RFC PATCH v19 0/8] mm: security: ro protection for dynamic data To: Matthew Wilcox CC: , , , , , , , , References: <20180313214554.28521-1-igor.stoppa@huawei.com> <20180314115653.GD29631@bombadil.infradead.org> <8623382b-cdbe-8862-8c2f-fa5bc6a1213a@huawei.com> <20180314130418.GG29631@bombadil.infradead.org> From: Igor Stoppa Message-ID: <9623b0d1-4ace-b3e7-b861-edba03b8a8cd@huawei.com> Date: Wed, 14 Mar 2018 18:11:22 +0200 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: <20180314130418.GG29631@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 14/03/18 15:04, Matthew Wilcox wrote: > I don't necessarily think you should use it as-is, I think I simply cannot use it as-is, because it seems to use linear memory, while I need virtual. This reason alone would require a rewrite of several parts. > but the principle it uses > seems like a better match to me than the rather complex genalloc. It uses meta data in a different way than genalloc. There is probably a tipping point where one implementation becomes more space-efficient than the other. Probably page_frag does well with relatively large allocations, while genalloc seems to be better for small (few allocation units) allocations. Also, in case of high variance in the size of the allocations, genalloc requires the allocation unit to be small enough to fit the smallest request (otherwise one must accept some slack), while page_frag doesn't care if the allocation is small or large. page_frag otoh, seems to not support the reuse of space that was freed, since there is only But could you please explain to what you are referring to, when you say that page_frag has "significantly lower overhead" ? Is it because it doesn't try to reclaim space that was freed, until the whole page is empty? I see different trade-offs, but I am probably either missing or underestimating the main reason why you think this is better. And probably I am missing the capability of judging what is acceptable in certain cases. Ex: if the pfree is called only on error paths, is it ok to not claim back the memory released, if it's less than one page? To be clear: I do not want to hold to genalloc just because I have already implemented it. I can at least sketch a version with page_frag, but I would like to understand why its trade-offs are better :-) > Just allocate some pages and track the offset within those pages that > is the current allocation point. > It's less than 100 lines of code! Strictly speaking it is true, but it all relies on other functions, which must be rewritten, because they use linear address, while this must work with virtual (vmalloc) addresses. Also, I see that the code relies a lot on order of allocation. I think we had similar discussion wrt compound pages. It seems to me wasteful, if I have a request of, say, 5 pages, and I end up allocating 8. I do not recall anyone giving a justification like: "yeah, it uses extra pages, but it's preferable, for reasons X, Y and Z, so it's a good trade-off" Could it be that it's normal RAM is considered less precious than the special memory genalloc is written for, so normal RAM is not really proactively reused, while special memory is treated as a more valuable resource that should not be wasted? -- igor