Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp44886pxu; Tue, 6 Oct 2020 18:14:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJydyealP13suJNDXP7lsakGxVTBZFySUQmvro/ZRMZUm6W42MI7il+3UQ17UGK4gsjFnzrJ X-Received: by 2002:a17:906:170e:: with SMTP id c14mr791953eje.275.1602033265958; Tue, 06 Oct 2020 18:14:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602033265; cv=none; d=google.com; s=arc-20160816; b=WsqQMaJgeu/cbd/UxGI3VFmH36JZkPa9vtpDsHGeWk/6Ja4i8kZDG18/xpxOCQR3C6 W6AuoCW/wXRVg/yvlqeMl6stV13GJ8BsDqFPNKGxEO7pp8UrXjSEEgT4YatZltLA1wkD hUm06Y9NoUq+723ju8uaiW2LcIZNY//aCuGOJ7/5z1L1JUIJsapek9EJ+OoPB0Z5aNZ5 wFOGg92JJ1I7/vqAu9ci9+6c4VL/5FFt6Z0ul2owbGUdneH2BS1A7pC31QavQPP/tLEK 7c6FH1kq6gg+lHl+7UuO/aAFkWSi1m5UDcIfub1k6Vua9UEzkVsO4IuI4udx4N5aGT9i dLtA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=AEDNEi43Y2zFaHkXpyai8k44psKmQxmMhyysaLVCBuw=; b=o1kY9OJyb/WVIw5Lg7ST576l4yV1aji3JqstEXBUoUYVbY/FoXTGQMdcPkBgZuq8iU bdoIDyTAgybQ/AYPxdJ3O0GGYNy7vryS6XUlrmZlF21b5qG2UoBvJ1jQ1Dj9fy/plaeY arTwq/qacUXGKefiItrGmC6beJHu614WW7m75+cMMzYnnwIuEr+d0bUNXI0PFg2muAFn MTcNlGSQQguAyvwowVb299o9vH4ZPMNKJxtTiSG8xVArOGWs1XqBaEq0WFG0XxZoILeJ LMr5cLdy2eiYCmvicyxQRTgMcpC//OBbZmhvJG0faEpWneRYpUbWUM9JDDr9Zc5rAxsU lkPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YXJPcMTH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si259779edv.348.2020.10.06.18.14.03; Tue, 06 Oct 2020 18:14:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=YXJPcMTH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726991AbgJGBHT (ORCPT + 99 others); Tue, 6 Oct 2020 21:07:19 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:52751 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726762AbgJGBHS (ORCPT ); Tue, 6 Oct 2020 21:07:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602032838; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AEDNEi43Y2zFaHkXpyai8k44psKmQxmMhyysaLVCBuw=; b=YXJPcMTHk9slMN5KzcAgV/fIQW5R7e+FMwCFhM9QufRz80Jisc1nAwEHeChQPgnZdTZeCq 7J88axk+LPEg3bKd+puhiHBMcgQ6+iOkttRuAQh7K88S9nnPIm7Xt4egVPXKqyGHzef62I cG3QViayDX7PTY3MczwRqYYCzetkNCg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-405-dSHIC1-_PceQL3n4lpcmtg-1; Tue, 06 Oct 2020 21:07:13 -0400 X-MC-Unique: dSHIC1-_PceQL3n4lpcmtg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3DB9B8015F6; Wed, 7 Oct 2020 01:07:12 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-119-161.rdu2.redhat.com [10.10.119.161]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48FFF5D9D2; Wed, 7 Oct 2020 01:07:11 +0000 (UTC) From: jglisse@redhat.com To: linux-kernel@vger.kernel.org Cc: =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Andrew Morton , Alexander Viro , linux-fsdevel@vger.kernel.org, Tejun Heo , Jan Kara , Josef Bacik Subject: [PATCH 01/14] mm/pxa: page exclusive access add header file for all helpers. Date: Tue, 6 Oct 2020 21:05:50 -0400 Message-Id: <20201007010603.3452458-2-jglisse@redhat.com> In-Reply-To: <20201007010603.3452458-1-jglisse@redhat.com> References: <20201007010603.3452458-1-jglisse@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jérôme Glisse Add include/linux/page-xa.h where all helpers related to Page eXclusive Acces (PXA) will be added (in following patches). Also introduce MAPPING_NULL as a temporary define use to simplify the mass modifications to stop relying on struct page.mapping and instead pass down mapping pointer from the context (either from inode when in syscall operating on a file or from vma->vm_file when operating on some virtual address. This is temporary define, do not use ! Signed-off-by: Jérôme Glisse Cc: Andrew Morton Cc: Alexander Viro Cc: linux-fsdevel@vger.kernel.org Cc: Tejun Heo Cc: Jan Kara Cc: Josef Bacik --- include/linux/mm.h | 5 ++++ include/linux/page-xa.h | 66 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 include/linux/page-xa.h diff --git a/include/linux/mm.h b/include/linux/mm.h index 16b799a0522cd..d165961c58c45 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3130,5 +3130,10 @@ unsigned long wp_shared_mapping_range(struct address_space *mapping, extern int sysctl_nr_trim_pages; + +/* Page exclusive access do depend on some helpers define in here. */ +#include + + #endif /* __KERNEL__ */ #endif /* _LINUX_MM_H */ diff --git a/include/linux/page-xa.h b/include/linux/page-xa.h new file mode 100644 index 0000000000000..8ac9e6dc051e0 --- /dev/null +++ b/include/linux/page-xa.h @@ -0,0 +1,66 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Page eXclusive Acess (PXA) is a generic mechanism to allow exclusive access + * to a file back or an anonymous page. Exclusive access means that no one can + * write to page except the owner of the protection (but the page can still be + * read). The exclusive access can be _broken_ at anytime and this can not be + * block (so anyone using that feature must be ready to give away the exclusive + * access at _any_ time and must do so in a timely fashion). + * + * Using PXA allows to implement few different features: + * - KSM (Kernel Shared Memory) where page with same content are deduplicated + * using a unique page and all mapping are updated to read only. This allow + * to save memory for workload with a lot of pages in different process that + * end up with same content (multiple VM for instance). + * + * - NUMA duplication (sort of the opposite of KSM) here a page is duplicated + * into multiple read only copy with each copy using physical memory local a + * NUMA node (or a device). This allow to improve performance by minimizing + * cross node memory transaction and also help minimizing bus traffic. It + * does however use more memory, so what you gain in performance you loose + * in available resources. + * + * - Exclusive write access to a page, for instance you can use regular write + * instruction and still get atomic behavior (as you are the only being able + * to write you the garantee that no one can race with you). + * + * And any other use cases you can think of ... + * + * See Documentation/vm/page-xa.rst for further informations. + * + * Authors: + * Jérôme Glisse + */ +#ifndef LINUX_PAGE_XA_H +#define LINUX_PAGE_XA_H + +#include +#include + + +/* + * MAPPING_NULL this is temporary define use to simplify the mass modificaitons + * to stop relying on struct page.mapping and instead pass down mapping pointer + * from the context (either from inode when in syscall operating on a file or + * from vma->vm_file when operating on some virtual address range). + * + * DO NOT USE ! THIS IS ONLY FOR SEMANTIC PATCHES SIMPLIFICATION ! + */ +#define MAPPING_NULL NULL + + +/** + * PageXA() - is page under exclusive acces ? + * + * This function checks if a page is under exclusive access. + * + * @page: Pointer to page to be queried. + * @Return: True, if it is under exclusive access, false otherwise. + */ +static inline bool PageXA(struct page *page) +{ + return false; +} + + +#endif /* LINUX_PAGE_XA_H */ -- 2.26.2