Received: by 10.192.165.148 with SMTP id m20csp3393370imm; Mon, 23 Apr 2018 05:58:02 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/ws2tiSfPNl3zGj41vc8WLx3dYu7xo/PWZYgIQXsJ5bGHtQxXHSLEtJfITsSPCzvVw/GsU X-Received: by 10.99.127.9 with SMTP id a9mr17360376pgd.347.1524488282717; Mon, 23 Apr 2018 05:58:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524488282; cv=none; d=google.com; s=arc-20160816; b=YNpUPB4otCzkS2SSbq3YrurXxUOcvcxda45Y5sRDxMU+MvSdvhgmoG6BDm15xQhgDz dcmPvwgvsJysg1eUJ7bBU+tv49pIwqTpafeIqs3B7WQyctJSI3NeMfWLiwnJZYq/bFSN 28li7gZJRkXozCImiBnWvMzvpScRn0aaH5fp+kSqh6tYk0HN4JeAzYAMNd4yHhWc4Av5 fzVCqeNuxhC+MkrzEDLaNa97yOXiemEteqrX7o4oQrqpKpMMnP3MfUq/0/aGcx1xb0E3 hlkLFdY9pVPmAsk/7yCFp5NHN1c+fu3l2bpHBxLw2id3WChpqZcZzFPq/cH1rgxnSdgy klGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=EibkUN8IJIqpJJK5IsXHteb/ZHMrTxt39Z45b4pq1jo=; b=ksUC07mGKsuOmfRlVeYpy9ZMRQlLFLAOdCx4XM8qddw+Qyc3fkCj5BsTfbxdxU1GaS Nc1ayHZyibv7OMtRUke1xfsAhKnVnVfFgBNd/6d4rSlkq11d1waaOzZ0UEogpXpk9Yk5 +3JydW/T3BZiXV6dpDLkDR+njwAbJ+IL9JhFAegP8TGoKKShBgn9enxhfP//8/nh+O6p tyOcjZPq8AnsYuVmpbFcl/QR2AGGbmH+C4+mhb9kodqO+rq4S2AFfLx5t6jbDezXi5Eb 5H4rGzsKRjbPUdupF6P5mwtli6U6GyTvTYMvDy+gEGad99wpZzy49tmSXRqL7gABihwk m6mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=KJhnLgxc; 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 a68-v6si6405175pli.158.2018.04.23.05.57.48; Mon, 23 Apr 2018 05:58:02 -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=KJhnLgxc; 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 S1755221AbeDWMzc (ORCPT + 99 others); Mon, 23 Apr 2018 08:55:32 -0400 Received: from mail-io0-f195.google.com ([209.85.223.195]:33661 "EHLO mail-io0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754718AbeDWMzY (ORCPT ); Mon, 23 Apr 2018 08:55:24 -0400 Received: by mail-io0-f195.google.com with SMTP id e78-v6so5734972iod.0; Mon, 23 Apr 2018 05:55:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=EibkUN8IJIqpJJK5IsXHteb/ZHMrTxt39Z45b4pq1jo=; b=KJhnLgxcdc71VEgRlCyL1DzLax2CrXcGSX06TycgRNdYwO+tDzDeZyareQw39wvj33 JwLqk1V3f+GaSWd/Ar0/zjrAQGm/5sh8efVHpcSghAkgRcTieWceMMnxYyxBmgeFbvTZ +DtOe6WXFWFwPIGhIBKv172UV8x6osk18AEhzf0qbGfgEE5qb+O/9SwkZT7YeIuluyXR WN0lTj/6rO+rP9Lmg/USEJhZW0lqpUS8lZpdaYZrsYRdKTMFLuqzKZq8Sf+8pzDAJoMX 0ivPNN0/Dbof8vy0W+TNnUhR5K504PA7gx+Wf7kHZu7bVBI83Hn4b0IANmRWpltDSRaB Slig== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=EibkUN8IJIqpJJK5IsXHteb/ZHMrTxt39Z45b4pq1jo=; b=o+v4cxQw+BE3GLNE8UFoVYkas8qZGuISFZI6f6DHq4pMr3hCuBpCmc3BFRlLx+0fGI /nQ2up0mLTrD1c/4juctpudgmR87Klz4aXrftInhelpWJd3pvM2K1g4MEvpmsHhifVzD bQjWXRCJMJhOQri69JJVLAok9j8CaWYL/xfXbfLZ6vIbCSnJWGYFGIKaFGyKrV5Ldyg2 wlg+r29D+dBwrHfdIbdaXpi1bY32A4P8QDf+vnrn/3I0Obm0kC+sY7XWN4u8V5yjNmjU ZZLOrFOyFHeNKSBjWDx+381NNgh2C7WY15Fqp+eKcCZPYkvi0kLw0tzDKtnSo6oxeAjc R5UQ== X-Gm-Message-State: ALQs6tDM3vxQmYEGYzqqvop0nHZTLKx1Gu/HtFNbVJGECtzu0IV1kxvV 955IROXxVljmD0KNesdNVU9M4VIg X-Received: by 2002:a6b:5109:: with SMTP id f9-v6mr491505iob.192.1524488124179; Mon, 23 Apr 2018 05:55:24 -0700 (PDT) Received: from Mort.huawei.com (174-23-152-165.slkc.qwest.net. [174.23.152.165]) by smtp.gmail.com with ESMTPSA id n67-v6sm5934417ioe.20.2018.04.23.05.55.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Apr 2018 05:55:23 -0700 (PDT) From: Igor Stoppa X-Google-Original-From: Igor Stoppa To: willy@infradead.org, keescook@chromium.org, paul@paul-moore.com, sds@tycho.nsa.gov, mhocko@kernel.org, corbet@lwn.net Cc: labbott@redhat.com, linux-cc=david@fromorbit.com, --cc=rppt@linux.vnet.ibm.com, --security-module@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com, igor.stoppa@gmail.com, Igor Stoppa Subject: [PATCH 1/9] struct page: add field for vm_struct Date: Mon, 23 Apr 2018 16:54:50 +0400 Message-Id: <20180423125458.5338-2-igor.stoppa@huawei.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20180423125458.5338-1-igor.stoppa@huawei.com> References: <20180423125458.5338-1-igor.stoppa@huawei.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When a page is used for virtual memory, it is often necessary to obtain a handler to the corresponding vm_struct, which refers to the virtually continuous area generated when invoking vmalloc. The struct page has a "mapping" field, which can be re-used, to store a pointer to the parent area. This will avoid more expensive searches, later on. Signed-off-by: Igor Stoppa Reviewed-by: Jay Freyensee Reviewed-by: Matthew Wilcox --- include/linux/mm_types.h | 1 + mm/vmalloc.c | 2 ++ 2 files changed, 3 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 21612347d311..c74e2aa9a48b 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -86,6 +86,7 @@ struct page { void *s_mem; /* slab first object */ atomic_t compound_mapcount; /* first tail page */ /* page_deferred_list().next -- second tail page */ + struct vm_struct *area; }; /* Second double word */ diff --git a/mm/vmalloc.c b/mm/vmalloc.c index ebff729cc956..61a1ca22b0f6 100644 --- a/mm/vmalloc.c +++ b/mm/vmalloc.c @@ -1536,6 +1536,7 @@ static void __vunmap(const void *addr, int deallocate_pages) struct page *page = area->pages[i]; BUG_ON(!page); + page->area = NULL; __free_pages(page, 0); } @@ -1705,6 +1706,7 @@ static void *__vmalloc_area_node(struct vm_struct *area, gfp_t gfp_mask, area->nr_pages = i; goto fail; } + page->area = area; area->pages[i] = page; if (gfpflags_allow_blocking(gfp_mask|highmem_mask)) cond_resched(); -- 2.14.1