Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp5931393imm; Wed, 12 Sep 2018 13:25:33 -0700 (PDT) X-Google-Smtp-Source: ANB0VdajdAPjy6gI8eCOcZmF685MntJSJnzf9Wf/vica7cEIYmdygAOtad5oeBFftU9Cb9z3zWMs X-Received: by 2002:a62:3306:: with SMTP id z6-v6mr4159476pfz.85.1536783933126; Wed, 12 Sep 2018 13:25:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536783933; cv=none; d=google.com; s=arc-20160816; b=IfkpS8FsfQKLKBL7POYkjvzkEAZ6ZiLutsvWBd46FzV2qiCRc02vZWuUMPfqOAfZP7 TaL5Df7P4FL+NpNJrVDmJf1RvTkhXFHU/bKMzwyExGxYpPMql2U3XV9Uy+b9DNCq+bMW Mx4aP1bS82TWXAWb+o7qt/jIxU9YuEmaaF2cVjr15AXStNcn7q9xuw/qUhzFyZR+TIgC rX4pbC024/zS7mS8dR7VDOrPV1SMH8qTmq1cZpHhkVXzvWS3UpJNcD+hjiZWe4seW3QU MJuEByxoYEzIPF1fU3snX7N6G0cp0V9iQls+H/7cHP9O5JWxjYP98fbennLxhrfmLS5p IOjA== 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; bh=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=hKIilRxHXP73DWRhqBYWYnL2D9R0I2KoW0mHbGWgbE72LHWaRtdUdedvpqwbN+94Mn p/Ep0evJ1l5UhvmGd27GjdknBv4pej32VA6Q+k4ltxaoUlHtpUibZzbOOzfJpKmE7pYH TlshbRTxIPynboVlGx5qQ4AKhd4wJKBhAmSKnlH2tisQtougo32WaKnoyZ+oBUrwfy9Y wx+15bwzpYr6EjZrQo8TvKrubx7RK/dSZRA7XzpqHAlkEZZ2uURV5muUKax8W95bStey cyBFQuaH5hFGo5kl8xua9AzHvNJ2KL9JO5VvvNKE0kpY05Yp1ia6aGx67eK494lsP2DF jPIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=P1lIUvk9; 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=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w3-v6si1954344ply.370.2018.09.12.13.25.18; Wed, 12 Sep 2018 13:25:33 -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=@oracle.com header.s=corp-2018-07-02 header.b=P1lIUvk9; 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=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728371AbeIMBbW (ORCPT + 99 others); Wed, 12 Sep 2018 21:31:22 -0400 Received: from aserp2120.oracle.com ([141.146.126.78]:49646 "EHLO aserp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727944AbeIMBbU (ORCPT ); Wed, 12 Sep 2018 21:31:20 -0400 Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w8CKO6LB084494; Wed, 12 Sep 2018 20:25:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references; s=corp-2018-07-02; bh=jv2gOdozZBt8RfOmySF/IIWmh2gd+llfLCyQhB8Gt2w=; b=P1lIUvk9b+Z/DAZVGAy2Zf58rJ1fc5O1bxJqkp5l86Uc0CM5X4v21jIKSNLipOGBqshd biWb7mlxkIwrHdorzdJBioUjaNaKIU+21qiMGcdEl65xwyLSnq39HU8G/KKEy2AYcM7B 6mJAhGjUrZdm4YVp06HHbidHBWta8hiFrJad2lfAAMMDtjYpWTtIWEYxoVqLYp3Zkqi5 1e7JKJZeO6aXNPdbpuSo1WZCEopRzF+SN1Kozre9TrqpOgCHdeA6/dM9quUG8DqwDWoK Fl6DD2zsDapfAuBX4FeWVt0yIJSxiaU+mcIQ4hkDVQ4cMnF7y3M1R0WBFiBiiEqjonKT 6A== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2120.oracle.com with ESMTP id 2mc6cpvd7h-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:01 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w8CKOxuQ010208 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 12 Sep 2018 20:25:00 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w8CKOxhK032107; Wed, 12 Sep 2018 20:24:59 GMT Received: from pp-ThinkCentre-M82.us.oracle.com (/10.132.93.61) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 12 Sep 2018 13:24:59 -0700 From: Prakash Sangappa To: linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: dave.hansen@intel.com, mhocko@suse.com, nao.horiguchi@gmail.com, akpm@linux-foundation.org, kirill.shutemov@linux.intel.com, khandual@linux.vnet.ibm.com, steven.sistare@oracle.com, prakash.sangappa@oracle.com Subject: [PATCH V2 4/6] Add support to lseek /proc//numa_vamaps file Date: Wed, 12 Sep 2018 13:24:02 -0700 Message-Id: <1536783844-4145-5-git-send-email-prakash.sangappa@oracle.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1536783844-4145-1-git-send-email-prakash.sangappa@oracle.com> References: <1536783844-4145-1-git-send-email-prakash.sangappa@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9014 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1809120201 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Allow lseeking to a process virtual address(VA), starting from where the address range to numa node information can be read. The lseek offset will be the process virtual address. Signed-off-by: Prakash Sangappa Reviewed-by: Steve Sistare --- fs/proc/task_mmu.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 1371e379..93dce46 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -1866,6 +1866,27 @@ static int gather_hole_info_vamap(unsigned long start, unsigned long end, return 0; } +static loff_t numa_vamaps_llseek(struct file *file, loff_t offset, int orig) +{ + struct numa_vamaps_private *nvm = file->private_data; + + if (orig == SEEK_CUR && offset < 0 && nvm->vm_start < -offset) + return -EINVAL; + + switch (orig) { + case SEEK_SET: + nvm->vm_start = offset & PAGE_MASK; + break; + case SEEK_CUR: + nvm->vm_start += offset; + nvm->vm_start = nvm->vm_start & PAGE_MASK; + break; + default: + return -EINVAL; + } + return nvm->vm_start; +} + static int vamap_vprintf(struct numa_vamaps_private *nvm, const char *f, ...) { va_list args; @@ -2052,7 +2073,7 @@ const struct file_operations proc_pid_numa_maps_operations = { const struct file_operations proc_numa_vamaps_operations = { .open = numa_vamaps_open, .read = numa_vamaps_read, - .llseek = noop_llseek, + .llseek = numa_vamaps_llseek, .release = numa_vamaps_release, }; #endif /* CONFIG_NUMA */ -- 2.7.4