Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753348AbdFSHN7 (ORCPT ); Mon, 19 Jun 2017 03:13:59 -0400 Received: from lhrrgout.huawei.com ([194.213.3.17]:28911 "EHLO lhrrgout.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750952AbdFSHN5 (ORCPT ); Mon, 19 Jun 2017 03:13:57 -0400 Subject: Re: [PATCH 2/4] Protectable Memory Allocator To: Laura Abbott , , , CC: , , , , , , , , References: <20170607123505.16629-1-igor.stoppa@huawei.com> <20170607123505.16629-3-igor.stoppa@huawei.com> From: Igor Stoppa Message-ID: <5dfc037e-4812-898b-b173-cd0d1a61a701@huawei.com> Date: Mon, 19 Jun 2017 10:12:22 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.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 X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020206.594779A6.00EF,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 7384faa52ba92cd125d8a5f1de64251b Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1126 Lines: 37 On 09/06/17 21:56, Laura Abbott wrote: > On 06/07/2017 05:35 AM, Igor Stoppa wrote: [...] > The pool logic looks remarkably similar to genalloc (lib/genalloc.c). > It's not a perfect 1-to-1 mapping but it's close enough to be worth > a look. Indeed. I have prepared a new incarnation of pmalloc, based on genalloc. There are a couple of things that I would like to adjust in genalloc, but I'll discuss this in the new submission. >> + >> +const char msg[] = "Not a valid Pmalloc object."; >> +const char *__pmalloc_check_object(const void *ptr, unsigned long n) >> +{ >> + unsigned long p; >> + >> + p = (unsigned long)ptr; >> + n = p + n - 1; >> + for (; (PAGE_MASK & p) <= (PAGE_MASK & n); p += PAGE_SIZE) { >> + if (is_vmalloc_addr((void *)p)) { >> + struct page *page; >> + >> + page = vmalloc_to_page((void *)p); >> + if (!(page && PagePmalloc(page))) >> + return msg; >> + } > > Should this be an error if is_vmalloc_addr returns false? Yes, if this function is called, at least the beginning of the range *is* a vmalloc address and therefore the rest should be a vmalloc address as well. thanks, igor