Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3262410ybl; Mon, 19 Aug 2019 15:22:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqzp4OI5924ZhtLcbvAKT+KBI3wDJNor6tEi0glbBBvV+s99UNun3el0Cgx86dDdmuvoQrfY X-Received: by 2002:aa7:939c:: with SMTP id t28mr17403179pfe.111.1566253343240; Mon, 19 Aug 2019 15:22:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566253343; cv=none; d=google.com; s=arc-20160816; b=toyO1NcgywcQb4V2gpKUlvI/y8EEOrVLhfhTGyLZXwBBXN8zVeY0TxHfalGbX9RJUv oXjkzaaEw9SOuQTd+Vppay9iEAZW8zJz5StfeoIqTA5dTKYBJXs7Y+ZSXzAYX7iX5CBS 1hQ8Z7cxbffa+go7cJ1Zhwc2JoUnf/+XWievTw+YaDtVEne8hexTxHhz5MYU60gLAxXl wrALuHOVwJA0D4f3DEJPET7UmUbio/CpPr1gQGV04+XAuO2DPKo4cVn6eqx1cG3PWf3v FeR2vR67OZk00xml8to5erlD93PrWrGW2Wz4RxqOpUkV10SAsdtIO2mNuC/qsboNoRiV aPlw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KR93Nh2pEVTQXskRCcRNJG5EoMuJxb1LL9zdGmo9ev8=; b=IP6BdoQlRvgfAjEWcAH69LMlBPI6dWMplsOQVnK7V5kt8MyT7+B4Ov9yjDoRpMp/pS acAexsqc/vE4DOqb5OAstKIEI04f/dK51Eipmzl9auhOgM3lJYpEbjR4YnhZ2oR8or99 tfUEsx0i5tS6h4xSOnw6ctZEzLWBK9s78kVuU/mT2N6Eve+jUzpeohRD6qPjb/P5eJvS 6jSwTilSJpY19iddqznT77UVTagV/Dx9WCeKJPCkI5+q07lpKYG3Q+zdfQ+pHd8bObQ6 zjtb8AweNzfdwTUVQ+qRq7hwy6pzxxn675sXo5i3wPLTNT+ON/FUmNYVQEBcwent7qqe HJEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="XGcvD/0M"; 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=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65si10872737ple.240.2019.08.19.15.22.07; Mon, 19 Aug 2019 15:22:23 -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=@kernel.org header.s=default header.b="XGcvD/0M"; 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=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728572AbfHSWVC (ORCPT + 99 others); Mon, 19 Aug 2019 18:21:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:34680 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbfHSWVC (ORCPT ); Mon, 19 Aug 2019 18:21:02 -0400 Received: from mail-wr1-f49.google.com (mail-wr1-f49.google.com [209.85.221.49]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 578F622DA7 for ; Mon, 19 Aug 2019 22:21:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1566253261; bh=KR93Nh2pEVTQXskRCcRNJG5EoMuJxb1LL9zdGmo9ev8=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=XGcvD/0M9vzUeS5avfGpqrqHbAXOoM7uu9ljKoE0xyKGAOK/T4rwZQ5k6bSHpqVZy OkuCiCQD0/WV82YQMrJnVLzUeStX/PHvdFGOvUencl1Htvm5Rq7zuoaJoyxWxg9qvu 808gminbEYHjFq2fq8o9F4ZuzVJo6fczFFK2iaQo= Received: by mail-wr1-f49.google.com with SMTP id k2so10290578wrq.2 for ; Mon, 19 Aug 2019 15:21:01 -0700 (PDT) X-Gm-Message-State: APjAAAW8PJhidoyu3KRANNhp/8O5aFp84uIbtLG6HtWnHEDVTV8Sqtgz a+GV2G/5KIPJirPFFBpHabFCzJRVHRRYbsiQtrIRdw== X-Received: by 2002:adf:eec5:: with SMTP id a5mr29877043wrp.352.1566253259728; Mon, 19 Aug 2019 15:20:59 -0700 (PDT) MIME-Version: 1.0 References: <20190815001636.12235-1-dja@axtens.net> <20190815001636.12235-2-dja@axtens.net> <15c6110a-9e6e-495c-122e-acbde6e698d9@c-s.fr> <20190816170813.GA7417@lakrids.cambridge.arm.com> <87imqtu7pc.fsf@dja-thinkpad.axtens.net> In-Reply-To: <87imqtu7pc.fsf@dja-thinkpad.axtens.net> From: Andy Lutomirski Date: Mon, 19 Aug 2019 15:20:47 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 1/3] kasan: support backing vmalloc space with real shadow memory To: Daniel Axtens Cc: Mark Rutland , Christophe Leroy , kasan-dev , Linux-MM , X86 ML , Andrey Ryabinin , Alexander Potapenko , Andrew Lutomirski , LKML , Dmitry Vyukov , linuxppc-dev , Vasily Gorbik Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Aug 18, 2019, at 8:58 PM, Daniel Axtens wrote: > >>> Each page of shadow memory represent 8 pages of real memory. Could we use >>> page_ref to count how many pieces of a shadow page are used so that we can >>> free it when the ref count decreases to 0. > > I'm not sure how much of a difference it will make, but I'll have a look. > There are a grand total of eight possible pages that could require a given shadow page. I would suggest that, instead of reference counting, you just check all eight pages. Or, better yet, look at the actual vm_area_struct and are where prev and next point. That should tell you exactly which range can be freed.