Received: by 2002:ac0:98c7:0:0:0:0:0 with SMTP id g7-v6csp3728790imd; Mon, 29 Oct 2018 11:23:32 -0700 (PDT) X-Google-Smtp-Source: AJdET5dcjlxI209EV29Llr2TpW1QpSWc5SGMh6x8nftU7YLbdbLFPrXMIs45Hy0ByQt1bwpqtMi1 X-Received: by 2002:a17:902:b784:: with SMTP id e4-v6mr15071614pls.45.1540837412000; Mon, 29 Oct 2018 11:23:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540837411; cv=none; d=google.com; s=arc-20160816; b=Mlx1jxw79Q5MUG3HKI4mVHw1m6lJeJtC4ubhY2wuHzuc2F6RlvaVJZraL8/NVZeSVZ ODWsVcS6AHf0ET7KCqlD8nfniTh5Cq82zJINsGfC7hWL6Ux3eFhtGgtY/g6BfliPu4qs 1j13IIpCstNozAnCD2kupUJSTvQU4f35ZTHSfrtfw4ze7erD1KlrojrDK8GDMqNIryhS gGg77sSFogaTIpJNEa8hDRVPziWTozJgsXyBG6XUNUlNGETLKTvcdZYWoy7vp0qhPjdt gCyqxYR/ZtmIHL0dTPVQKr7j2BwSqlF4/3I5+jeZuZPav/glsTQRfDMbVuyj4l+/xZDG gNhg== 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:dkim-signature; bh=ts1+JJpqKPjlm5tD26SVyb5IaS4Vf+MvFj6AodJ0bRA=; b=H0c/RUst3pqDyu6tZCsF6JSnS/xO/fbAF9vAr+RJqzzV+WwtiMbz9GauIIg9qBhkLO ihtwQ5wk94LKGjq60Jy2JRY+4IsnjHuqbNdlwxce6FQdYGMtF7ABO4vSSEhAxTGXyhcc fP24cnmYk4yCfvBmpx8VRQKvfZ0/ysBmWoP6VxzDfn43uHuVteLSfxjEd4t/ReR1Cq1/ y8g9xYzAbGKNQtG8qlFLumYStjY5QCQUnWRLgOU6f5tMmEthSmY5ilSN8UZpdT17B7XG HuGhCtWWEa6mmIeKkHM2AhfP/SSrS55JLOyX2FFU2s4eW+8A1axQdOgFq98q90AqNSty dJKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YaECEUDx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h38-v6si11503371pgi.86.2018.10.29.11.23.16; Mon, 29 Oct 2018 11:23:31 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YaECEUDx; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729359AbeJ3DLL (ORCPT + 99 others); Mon, 29 Oct 2018 23:11:11 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:37375 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726852AbeJ3DLL (ORCPT ); Mon, 29 Oct 2018 23:11:11 -0400 Received: by mail-lj1-f193.google.com with SMTP id c4-v6so8790864lja.4; Mon, 29 Oct 2018 11:21:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=ts1+JJpqKPjlm5tD26SVyb5IaS4Vf+MvFj6AodJ0bRA=; b=YaECEUDxehV8xiSwQSMYAb2Htjz6xhLoLrQzkicgjxYuBn5oxTxR6xWqbm9DWYepd8 qsSjg0aXP78yyb9wgZyQY8nQ4z1IFW0y+WauF3yj9/EL3pNTD/9aUMwtnlBcqKLnJC8Y AS360+xAMAR9vRkAMZvXN4Fowd5qgoKTVlH4yze5o1WGedliRrtjnkekg99YWEVARh6i Nrs6UQcee8ZJFgEFPkISPB377K9LdzfJTbaw2J4ovmP796GDgw0xnLzqGYC68xcDG/tZ k249yK1g+73202JPsivDbJPJXv1VpF1YoGYIpvtm3OnquSP2t1z40VloMEZZXMxxJLUK VEpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ts1+JJpqKPjlm5tD26SVyb5IaS4Vf+MvFj6AodJ0bRA=; b=UouWUpvo8JBBHt1VxV0nZOmnfenbA0TCLPAiYyQut4HJDmd/NlbDZsgkTLsn5gIXhz 4FQxEBOu1xUEZs7DyPXTPj9NZyxxfliCIAxLWqaKzqFtsOljJCQ0GWGc3fiCfqDOf6GH 0r5uDHKSJHqMdiFOHKLv29k0LtDSH8a9PCUmWg/UaRdj+iyORNrOcmAgpPrucaHrLRzT kGF4M/9xgsJO0SBm/F1fkd09/AIGPT2hyvmgYsTx+CTitLAWx0tdbj3NFLloMfuvuyin OX4bUfUPZd1xIMt1ECsDyIER9WyQL/b+D8sGdXynN9Q1NoHvw2prFiLP6yOvcvczMvO3 wl/A== X-Gm-Message-State: AGRZ1gKK46m4v2qg641JLUplznltBkyHRLM1utK8E6j6o/SLdpZBpjXD 7xJrq2ihVBNspDL8MMv3UBzlLLKynLK9Gg== X-Received: by 2002:a2e:5c89:: with SMTP id q131-v6mr10693964ljb.119.1540837281132; Mon, 29 Oct 2018 11:21:21 -0700 (PDT) Received: from ?IPv6:2001:14bb:52:7be:f0bf:dd2d:f008:5213? (dmkd798g-7z2-yccwcp-4.rev.dnainternet.fi. [2001:14bb:52:7be:f0bf:dd2d:f008:5213]) by smtp.gmail.com with ESMTPSA id u20-v6sm3315603lfk.55.2018.10.29.11.21.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Oct 2018 11:21:20 -0700 (PDT) Subject: Re: [PATCH 08/17] prmem: struct page: track vmap_area To: Matthew Wilcox Cc: Mimi Zohar , Kees Cook , Dave Chinner , James Morris , Michal Hocko , kernel-hardening@lists.openwall.com, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org, igor.stoppa@huawei.com, Dave Hansen , Jonathan Corbet , Laura Abbott , Vlastimil Babka , "Kirill A. Shutemov" , Andrew Morton , Pavel Tatashin , linux-mm@kvack.org, linux-kernel@vger.kernel.org References: <20181023213504.28905-1-igor.stoppa@huawei.com> <20181023213504.28905-9-igor.stoppa@huawei.com> <20181024031200.GC25444@bombadil.infradead.org> <20181025021307.GH25444@bombadil.infradead.org> From: Igor Stoppa Message-ID: <4b1ed33c-9b3c-a61f-b919-aeed97edddac@gmail.com> Date: Mon, 29 Oct 2018 20:21:18 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: <20181025021307.GH25444@bombadil.infradead.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 25/10/2018 03:13, Matthew Wilcox wrote: > On Thu, Oct 25, 2018 at 02:01:02AM +0300, Igor Stoppa wrote: >>>> @@ -1747,6 +1750,10 @@ void *__vmalloc_node_range(unsigned long size, unsigned long align, >>>> if (!addr) >>>> return NULL; >>>> + va = __find_vmap_area((unsigned long)addr); >>>> + for (i = 0; i < va->vm->nr_pages; i++) >>>> + va->vm->pages[i]->area = va; >>> >>> I don't like it that you're calling this for _every_ vmalloc() caller >>> when most of them will never use this. Perhaps have page->va be initially >>> NULL and then cache the lookup in it when it's accessed for the first time. >>> >> >> If __find_vmap_area() was part of the API, this loop could be left out from >> __vmalloc_node_range() and the user of the allocation could initialize the >> field, if needed. >> >> What is the reason for keeping __find_vmap_area() private? > > Well, for one, you're walking the rbtree without holding the spinlock, > so you're going to get crashes. I don't see why we shouldn't export > find_vmap_area() though. Argh, yes, sorry. But find_vmap_area() would be enough for what I need. > Another way we could approach this is to embed the vmap_area in the > vm_struct. It'd require a bit of juggling of the alloc/free paths in > vmalloc, but it might be worthwhile. I have a feeling of unease about the whole vmap_area / vm_struct duality. They clearly are different types, with different purposes, but here and there there are functions that are named after some "area", yet they actually refer to vm_struct pointers. I wouldn't mind spending some time understanding the reason for this apparently bizarre choice, but after I have emerged from the prmem swamp. For now I'd stick to find_vmap_area(). -- igor