From patchwork Tue Mar 17 19:31:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 11443843 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8781F6CA for ; Tue, 17 Mar 2020 19:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6531720754 for ; Tue, 17 Mar 2020 19:32:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jiIM9lHY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbgCQTcV (ORCPT ); Tue, 17 Mar 2020 15:32:21 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54457 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgCQTcV (ORCPT ); Tue, 17 Mar 2020 15:32:21 -0400 Received: by mail-wm1-f67.google.com with SMTP id n8so556695wmc.4; Tue, 17 Mar 2020 12:32:20 -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:mime-version :content-transfer-encoding; bh=2XX4av8BnQU6e6Q+23VgYpg7tfVGDDTS18cCb+m0Cnw=; b=jiIM9lHYCWJsyJYYKw/eUmEOJiRPiA3aEmTJcqBRnVL+QGoUGWKGHCYVtY2pMOxQ1v ryheDWKm6/z2USIYYGlELv4mvdDJkHFlnCnjC/p4iKXAYQ6k7v2aEWIYZYOVC8VbKhLb Gr1XGJPP++W2VBkjrD3eUY7MlvJwjN+1nmdqRjNjvNbNndbbNZnsyJ6B4rn5cvYgENwA v/nG1570bie4b7+DnRuxZ21Q+crpwji1z2X4pabkuxHj6/iP2opx6ttDkHZ8+7DvHrng H0Lh1ph5fxe3rP3KOva9w55LRvG8poF5FjXWOruFvIue2p+fKxb1B8+T6P8MpsCpqQT+ CkNQ== 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:mime-version :content-transfer-encoding; bh=2XX4av8BnQU6e6Q+23VgYpg7tfVGDDTS18cCb+m0Cnw=; b=pDXOoRO6x7dcRxXl4N0mvsFBNbgEHbbOIbAzJLVmVg3hFV0cVx5ry0vIvRZtLJcFrw sn5poiVGP7OYohpfUwxu87oI3jdTKd07EBauCVmNAh0PtXtI7l+0K4p364VsQoSGoGCN HSXNe2NjG60sVan2MamgHmQQpKjDPD2CfZBgTP8Zl/6vZXSIV6KDq6lZ9/d1NVox+aoR nhi2wGiSHRh5MKAeRWpxNujyRAmnL2jPMqEJ7gq0y9TKhEyFlWQDe43HLBAjAyj1yNR9 QChPfb8adGxvKI8heibaIV0+ay8A06MxaQG4wF8F2Jdmna+F4hzl0t6m0utCp8wlLlrf IewA== X-Gm-Message-State: ANhLgQ0vy9Gf8yz4myoqVQjGgAxYMb69dIsrSkkU48qwF9V1pwe1EA1h N+EzjCWetcKMRHohY7E7jQ== X-Google-Smtp-Source: ADFU+vscvNdlS7W3wTEb5lVjwADvZtMOhQtwRZBnBmvJ9Jb1GYuGAULitlstbaS8mZ8IrVbyxspSgA== X-Received: by 2002:a7b:c189:: with SMTP id y9mr545264wmi.47.1584473539381; Tue, 17 Mar 2020 12:32:19 -0700 (PDT) Received: from avx2.telecom.by ([46.53.254.169]) by smtp.gmail.com with ESMTPSA id t1sm5946323wrq.36.2020.03.17.12.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 12:32:18 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: willy@infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, adobriyan@gmail.com Subject: [PATCH 1/5] proc: inline vma_stop into m_stop Date: Tue, 17 Mar 2020 22:31:57 +0300 Message-Id: <20200317193201.9924-1-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: "Matthew Wilcox (Oracle)" Instead of calling vma_stop() from m_start() and m_next(), do its work in m_stop(). Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Alexey Dobriyan --- fs/proc/task_mmu.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 9442631fd4af..41f63df4789d 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -123,15 +123,6 @@ static void release_task_mempolicy(struct proc_maps_private *priv) } #endif -static void vma_stop(struct proc_maps_private *priv) -{ - struct mm_struct *mm = priv->mm; - - release_task_mempolicy(priv); - up_read(&mm->mmap_sem); - mmput(mm); -} - static struct vm_area_struct * m_next_vma(struct proc_maps_private *priv, struct vm_area_struct *vma) { @@ -163,11 +154,16 @@ static void *m_start(struct seq_file *m, loff_t *ppos) return ERR_PTR(-ESRCH); mm = priv->mm; - if (!mm || !mmget_not_zero(mm)) + if (!mm || !mmget_not_zero(mm)) { + put_task_struct(priv->task); + priv->task = NULL; return NULL; + } if (down_read_killable(&mm->mmap_sem)) { mmput(mm); + put_task_struct(priv->task); + priv->task = NULL; return ERR_PTR(-EINTR); } @@ -195,7 +191,6 @@ static void *m_start(struct seq_file *m, loff_t *ppos) if (pos == mm->map_count && priv->tail_vma) return priv->tail_vma; - vma_stop(priv); return NULL; } @@ -206,21 +201,22 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos) (*pos)++; next = m_next_vma(priv, v); - if (!next) - vma_stop(priv); return next; } static void m_stop(struct seq_file *m, void *v) { struct proc_maps_private *priv = m->private; + struct mm_struct *mm = priv->mm; - if (!IS_ERR_OR_NULL(v)) - vma_stop(priv); - if (priv->task) { - put_task_struct(priv->task); - priv->task = NULL; - } + if (!priv->task) + return; + + release_task_mempolicy(priv); + up_read(&mm->mmap_sem); + mmput(mm); + put_task_struct(priv->task); + priv->task = NULL; } static int proc_maps_open(struct inode *inode, struct file *file, From patchwork Tue Mar 17 19:31:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 11443841 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 86EEE1392 for ; Tue, 17 Mar 2020 19:32:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6568520753 for ; Tue, 17 Mar 2020 19:32:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MQBGgdIc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbgCQTcX (ORCPT ); Tue, 17 Mar 2020 15:32:23 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:54462 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgCQTcW (ORCPT ); Tue, 17 Mar 2020 15:32:22 -0400 Received: by mail-wm1-f67.google.com with SMTP id n8so556805wmc.4; Tue, 17 Mar 2020 12:32:22 -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 :mime-version:content-transfer-encoding; bh=ricf2BdJdyy+MI+5dglcQZRK8QJ6f3OrAioatix4nI4=; b=MQBGgdIc2wwxwDHci9iOL34Nke69ZJWu8B5sq+F9EWNu+mUpHYe4fvuKEh2ot156GK eCjON/Up/2p+w0n4RGRP3z9ikGAlV8KaG9gHqmJpaDdjlxXVdrmeb+FZXzIEkRi414ce VQ4sPfa0xH+7InypWkujQLexO4/y1DQDSgIxkFPNlnbW0TJyKX68Ct4lXjmB0DJdTMjK nEGuyrGC9Q8RMouLezhkCkCX/TsO4iNpPCfIL232DB2WcaIThuB4NojUtcDGP+P37F7D A4sHfCeu9Gb3ZaorFoggJVCReOwg/3Y7pDPSTVJvitreABMr3HxK7b5cou67f5jDEj8y I6gg== 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:mime-version:content-transfer-encoding; bh=ricf2BdJdyy+MI+5dglcQZRK8QJ6f3OrAioatix4nI4=; b=U3bfkWoywxZYQ4N5X1KxtLZqlYDD8vGn5WGBCCjOnerbVezdCG3cHOiyMya3Elu08x X6BSp+hi9FmcKJZz/OVJz0eJ5qb61fN9/R9/JcrR1pH1w8cws6xFA8kal5ow/8GS9QVt wu04mvTO9UHfnVQUQvavYTeWCrEA+/F3C27liKugFMy4iSuOjxqGAu3c7/3YQOlMXe5S PLNaa0fQfQ6/rkvTDKY03+/LRS4slaxWmO04HRAdNBkZQFpHMHjg0FFyonQZtdaaAbEz RBP3Ecw5UcPRhlRms3sCcV1o7TAncXZdp5y9KRNRWDnVn/hF6LHncYn2lLN1bPOlA0Wh qOkw== X-Gm-Message-State: ANhLgQ1+RoMnlZAhTh/9U+4dgSqzt2vpWmJFCDb9sGo7NtZZs+R9Qa6e Mgr4QnCiXP3kYdwAWDd8YA== X-Google-Smtp-Source: ADFU+vvxZVQupZ78DRnmyyAffSMYsm5xmCWlr5bozfSNvDevSrGn3UYQDd5MKjqTqrexbeXypIArbQ== X-Received: by 2002:a7b:c341:: with SMTP id l1mr557574wmj.146.1584473541281; Tue, 17 Mar 2020 12:32:21 -0700 (PDT) Received: from avx2.telecom.by ([46.53.254.169]) by smtp.gmail.com with ESMTPSA id t1sm5946323wrq.36.2020.03.17.12.32.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 12:32:20 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: willy@infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, adobriyan@gmail.com Subject: [PATCH 2/5] proc: remove m_cache_vma Date: Tue, 17 Mar 2020 22:31:58 +0300 Message-Id: <20200317193201.9924-2-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200317193201.9924-1-adobriyan@gmail.com> References: <20200317193201.9924-1-adobriyan@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: "Matthew Wilcox (Oracle)" Instead of setting m->version in the show method, set it in m_next(), where it should be. Also remove the fallback code for failing to find a vma, or version being zero. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Alexey Dobriyan --- fs/proc/task_mmu.c | 38 ++++++-------------------------------- 1 file changed, 6 insertions(+), 32 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 41f63df4789d..ff40d5d79f24 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -131,21 +131,14 @@ m_next_vma(struct proc_maps_private *priv, struct vm_area_struct *vma) return vma->vm_next ?: priv->tail_vma; } -static void m_cache_vma(struct seq_file *m, struct vm_area_struct *vma) -{ - if (m->count < m->size) /* vma is copied successfully */ - m->version = m_next_vma(m->private, vma) ? vma->vm_end : -1UL; -} - static void *m_start(struct seq_file *m, loff_t *ppos) { struct proc_maps_private *priv = m->private; unsigned long last_addr = m->version; struct mm_struct *mm; struct vm_area_struct *vma; - unsigned int pos = *ppos; - /* See m_cache_vma(). Zero at the start or after lseek. */ + /* See m_next(). Zero at the start or after lseek. */ if (last_addr == -1UL) return NULL; @@ -170,28 +163,11 @@ static void *m_start(struct seq_file *m, loff_t *ppos) hold_task_mempolicy(priv); priv->tail_vma = get_gate_vma(mm); - if (last_addr) { - vma = find_vma(mm, last_addr - 1); - if (vma && vma->vm_start <= last_addr) - vma = m_next_vma(priv, vma); - if (vma) - return vma; - } - - m->version = 0; - if (pos < mm->map_count) { - for (vma = mm->mmap; pos; pos--) { - m->version = vma->vm_start; - vma = vma->vm_next; - } + vma = find_vma(mm, last_addr); + if (vma) return vma; - } - - /* we do not bother to update m->version in this case */ - if (pos == mm->map_count && priv->tail_vma) - return priv->tail_vma; - return NULL; + return priv->tail_vma; } static void *m_next(struct seq_file *m, void *v, loff_t *pos) @@ -201,6 +177,8 @@ static void *m_next(struct seq_file *m, void *v, loff_t *pos) (*pos)++; next = m_next_vma(priv, v); + m->version = next ? next->vm_start : -1UL; + return next; } @@ -359,7 +337,6 @@ show_map_vma(struct seq_file *m, struct vm_area_struct *vma) static int show_map(struct seq_file *m, void *v) { show_map_vma(m, v); - m_cache_vma(m, v); return 0; } @@ -843,8 +820,6 @@ static int show_smap(struct seq_file *m, void *v) seq_printf(m, "ProtectionKey: %8u\n", vma_pkey(vma)); show_smap_vma_flags(m, vma); - m_cache_vma(m, vma); - return 0; } @@ -1883,7 +1858,6 @@ static int show_numa_map(struct seq_file *m, void *v) seq_printf(m, " kernelpagesize_kB=%lu", vma_kernel_pagesize(vma) >> 10); out: seq_putc(m, '\n'); - m_cache_vma(m, vma); return 0; } From patchwork Tue Mar 17 19:31:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 11443837 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 545CF1392 for ; Tue, 17 Mar 2020 19:32:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 306C02076B for ; Tue, 17 Mar 2020 19:32:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ExojwpsO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726783AbgCQTc1 (ORCPT ); Tue, 17 Mar 2020 15:32:27 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:41230 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbgCQTcZ (ORCPT ); Tue, 17 Mar 2020 15:32:25 -0400 Received: by mail-wr1-f67.google.com with SMTP id f11so10471012wrp.8; Tue, 17 Mar 2020 12:32: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 :mime-version:content-transfer-encoding; bh=mFBe8SVNMk8NQ0Cg/QItB1GqMx3KA9maWgv9PhH0jlI=; b=ExojwpsOYrw9jNcEILxqwlqDbYs2+T3W9Bxla2mm+2xgjNUcKz+Qt1gOyDEOVhmP25 iHqDSFdxlRx6z2xS/ITZFKAF1RpmOEKgPPZfIuNoL9JiWR5qP9/7i4tmGXO2uNGDFdWp xddeLk69emf+MA/kpAqwidDVKInIMavAVEmArRCNJmy5wi0OM2/etWk/3hHRcz47mY8s hD7MFxBw+lpa0OW+M/WUePEbKpTU5TtPQvagHuoJk5NTuHHoGLDyto1GmxlB8hlzrtcs q2J1Zzwfrw8IYdqD5YZVDY3NM4gcclIS0k/j5WMEFTYhXNMOxlN9MKUaq0/m1t3DRt+H EDgA== 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:mime-version:content-transfer-encoding; bh=mFBe8SVNMk8NQ0Cg/QItB1GqMx3KA9maWgv9PhH0jlI=; b=meTunc1GJCAhjZGhpfjuW8CpYoPFySmUVzFemqMJRWpLzZY1qe/FHiiBTLDHlTNzlB XFrdCdDsuIodQnOAsH/cJbSdaRuzrNJxk3MgwKaxYimGrLW6e6nVTH4Y96Ylq5L6+qYM rhQULAVcQGP5FrfdZZs7DhhFY2oit156BQ1MeAaUkmtgXq6Q7bxJXazFDJqaweohNsfL stBSwbV5gQa4tSF601amW4W3z5eHOvvjEWVsZuOihwmJko3mNlasYZ2S1XoWrzNNKOzu eIK3Ux47+5jh6T/zjTJoVFq3lOmedCAoDbXXZtC2QSCiBPCHgobiXB27sh6SFgh0ZiJG xfyg== X-Gm-Message-State: ANhLgQ2obyUjKRU+Nb9bwPaKAzb3w3znMNaM3dRNV96s0mac4U5VCH0R 35YanKIlUFhmpoPq8kqpZeshA7M= X-Google-Smtp-Source: ADFU+vtR/cAJQtnRHSKPRb6ac82+gTJz0ySapTCYJNA8csRijl2D3EJ6n1KfHg7MmJEoMZhuvFUDEw== X-Received: by 2002:adf:91c3:: with SMTP id 61mr594754wri.384.1584473543461; Tue, 17 Mar 2020 12:32:23 -0700 (PDT) Received: from avx2.telecom.by ([46.53.254.169]) by smtp.gmail.com with ESMTPSA id t1sm5946323wrq.36.2020.03.17.12.32.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 12:32:22 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: willy@infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, adobriyan@gmail.com Subject: [PATCH 3/5] proc: use ppos instead of m->version Date: Tue, 17 Mar 2020 22:31:59 +0300 Message-Id: <20200317193201.9924-3-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200317193201.9924-1-adobriyan@gmail.com> References: <20200317193201.9924-1-adobriyan@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: "Matthew Wilcox (Oracle)" The ppos is a private cursor, just like m->version. Use the canonical cursor, not a special one. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Alexey Dobriyan --- fs/proc/task_mmu.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index ff40d5d79f24..9f10ef72b839 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -134,7 +134,7 @@ m_next_vma(struct proc_maps_private *priv, struct vm_area_struct *vma) static void *m_start(struct seq_file *m, loff_t *ppos) { struct proc_maps_private *priv = m->private; - unsigned long last_addr = m->version; + unsigned long last_addr = *ppos; struct mm_struct *mm; struct vm_area_struct *vma; @@ -170,14 +170,13 @@ static void *m_start(struct seq_file *m, loff_t *ppos) return priv->tail_vma; } -static void *m_next(struct seq_file *m, void *v, loff_t *pos) +static void *m_next(struct seq_file *m, void *v, loff_t *ppos) { struct proc_maps_private *priv = m->private; struct vm_area_struct *next; - (*pos)++; next = m_next_vma(priv, v); - m->version = next ? next->vm_start : -1UL; + *ppos = next ? next->vm_start : -1UL; return next; } From patchwork Tue Mar 17 19:32:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 11443839 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 20FD76CA for ; Tue, 17 Mar 2020 19:32:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EB64320753 for ; Tue, 17 Mar 2020 19:32:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Y0OOHHl+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726840AbgCQTcd (ORCPT ); Tue, 17 Mar 2020 15:32:33 -0400 Received: from mail-wr1-f68.google.com ([209.85.221.68]:39701 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726452AbgCQTc0 (ORCPT ); Tue, 17 Mar 2020 15:32:26 -0400 Received: by mail-wr1-f68.google.com with SMTP id h6so6908457wrs.6; Tue, 17 Mar 2020 12:32:25 -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 :mime-version:content-transfer-encoding; bh=87R7ZZi7NQyiEUU6RgzITGKZd1KvjxPY9U+w9OVjGpQ=; b=Y0OOHHl+Qdc/0Q9l15Ho+69A+yKW8ocW48UbZhKhwCKIe6kSO/wWwBhSv8g1SrcgIo NFkEb3p0iBaRyfQSIl07hTPnBCownJtQbziJkfCP2cVyiIPdaNRTG7QcQZANHfz54Xrc oFDHaLvCb4b7przupJMoxQm6kdJSyuEINuPSJGbBT7lLpLbiDR2KhDeOxvE54lfSabQL beeOnd5m++aYaPPLUhcOYbhuBoTkYbGmFCLREMd7nXi06D6/QvyufLSGkUcKwJbMCIxY HrEKYX2KoZbas6fEwlMqBAE1+whC26twAjqOZ7dH//RSc0HTvNnetH8CeDJR5/Z7srBa 6PXg== 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:mime-version:content-transfer-encoding; bh=87R7ZZi7NQyiEUU6RgzITGKZd1KvjxPY9U+w9OVjGpQ=; b=gjUWuSqr67l0TlYug+HcmfqtgJQXhIrXKNMbDwVmH9rOWoQGGAeFiVE6wKVFzTcAxt biz72FcLzWjCsGEHdOHslaaXSrMzKZaeMtGb1MIqfoylcqNfVkKkCoFmJz8c14hwyGKy ZgFDVqVkNyivNeBna5xId+y7z3hPfzvGWTCrCnBNKwAc+rnOIBcqPQydWiqV2qx+QiFJ 9PhIzTJUTAxaDNsSHFA3Rbx+eXv5JdJ6Got7K4Vm5AYLvtVdN0X3nhMsceY8GN+l1X/N Llk7WD/SNcplN/Q9yBl+o0SjmZSJ3jRVfptX0QGRbX8P36OYpXlH3Q+20XV2qhJRi2Ft ChuA== X-Gm-Message-State: ANhLgQ3TmnZlW3kFrRKCg79eVGKPehHNKcjxz+ZL9MgoqFOb9E01yECZ 8RrnECH04GshlC0vuRGhZA== X-Google-Smtp-Source: ADFU+vvK9jJj5EXaKRlLWpStr34inD+bY6H/SGtK5gnUpY8GVbBY9v8S0OVBNCvZ4mPDvjrPyYEC5w== X-Received: by 2002:adf:ea88:: with SMTP id s8mr669701wrm.124.1584473544891; Tue, 17 Mar 2020 12:32:24 -0700 (PDT) Received: from avx2.telecom.by ([46.53.254.169]) by smtp.gmail.com with ESMTPSA id t1sm5946323wrq.36.2020.03.17.12.32.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 12:32:24 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: willy@infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, adobriyan@gmail.com Subject: [PATCH 4/5] seq_file: remove m->version Date: Tue, 17 Mar 2020 22:32:00 +0300 Message-Id: <20200317193201.9924-4-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200317193201.9924-1-adobriyan@gmail.com> References: <20200317193201.9924-1-adobriyan@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: "Matthew Wilcox (Oracle)" The process maps file was the only user of version (introduced back in 2005). Now that it uses ppos instead, we can remove it. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Alexey Dobriyan --- fs/seq_file.c | 28 ---------------------------- include/linux/seq_file.h | 1 - 2 files changed, 29 deletions(-) diff --git a/fs/seq_file.c b/fs/seq_file.c index 1600034a929b..79781ebd2145 100644 --- a/fs/seq_file.c +++ b/fs/seq_file.c @@ -67,13 +67,6 @@ int seq_open(struct file *file, const struct seq_operations *op) // to the lifetime of the file. p->file = file; - /* - * Wrappers around seq_open(e.g. swaps_open) need to be - * aware of this. If they set f_version themselves, they - * should call seq_open first and then set f_version. - */ - file->f_version = 0; - /* * seq_files support lseek() and pread(). They do not implement * write() at all, but we clear FMODE_PWRITE here for historical @@ -94,7 +87,6 @@ static int traverse(struct seq_file *m, loff_t offset) int error = 0; void *p; - m->version = 0; m->index = 0; m->count = m->from = 0; if (!offset) @@ -160,26 +152,12 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) mutex_lock(&m->lock); - /* - * seq_file->op->..m_start/m_stop/m_next may do special actions - * or optimisations based on the file->f_version, so we want to - * pass the file->f_version to those methods. - * - * seq_file->version is just copy of f_version, and seq_file - * methods can treat it simply as file version. - * It is copied in first and copied out after all operations. - * It is convenient to have it as part of structure to avoid the - * need of passing another argument to all the seq_file methods. - */ - m->version = file->f_version; - /* * if request is to read from zero offset, reset iterator to first * record as it might have been already advanced by previous requests */ if (*ppos == 0) { m->index = 0; - m->version = 0; m->count = 0; } @@ -190,7 +168,6 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) if (err) { /* With prejudice... */ m->read_pos = 0; - m->version = 0; m->index = 0; m->count = 0; goto Done; @@ -243,7 +220,6 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) m->buf = seq_buf_alloc(m->size <<= 1); if (!m->buf) goto Enomem; - m->version = 0; p = m->op->start(m, &m->index); } m->op->stop(m, p); @@ -287,7 +263,6 @@ ssize_t seq_read(struct file *file, char __user *buf, size_t size, loff_t *ppos) *ppos += copied; m->read_pos += copied; } - file->f_version = m->version; mutex_unlock(&m->lock); return copied; Enomem: @@ -313,7 +288,6 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence) loff_t retval = -EINVAL; mutex_lock(&m->lock); - m->version = file->f_version; switch (whence) { case SEEK_CUR: offset += file->f_pos; @@ -329,7 +303,6 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence) /* with extreme prejudice... */ file->f_pos = 0; m->read_pos = 0; - m->version = 0; m->index = 0; m->count = 0; } else { @@ -340,7 +313,6 @@ loff_t seq_lseek(struct file *file, loff_t offset, int whence) file->f_pos = offset; } } - file->f_version = m->version; mutex_unlock(&m->lock); return retval; } diff --git a/include/linux/seq_file.h b/include/linux/seq_file.h index 5998e1f4ff06..0d434bc4a779 100644 --- a/include/linux/seq_file.h +++ b/include/linux/seq_file.h @@ -21,7 +21,6 @@ struct seq_file { size_t pad_until; loff_t index; loff_t read_pos; - u64 version; struct mutex lock; const struct seq_operations *op; int poll_event; From patchwork Tue Mar 17 19:32:01 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Dobriyan X-Patchwork-Id: 11443835 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9378E1392 for ; Tue, 17 Mar 2020 19:32:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 669CF20754 for ; Tue, 17 Mar 2020 19:32:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ga94Wv3Q" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726823AbgCQTc3 (ORCPT ); Tue, 17 Mar 2020 15:32:29 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:44868 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726797AbgCQTc2 (ORCPT ); Tue, 17 Mar 2020 15:32:28 -0400 Received: by mail-wr1-f66.google.com with SMTP id y2so11763778wrn.11; Tue, 17 Mar 2020 12:32:27 -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 :mime-version:content-transfer-encoding; bh=Lkrlnh41qEla6doz611nE2A+6RV961H8nQhZ4jF0FBc=; b=ga94Wv3QbxmIG+2zHQj69KekHTY2A/PZdhbtGvL23ZPWaG0bRdKbtKxOwvYImXiZtK dfFs2H9QJiuyK92EKJCq2fFn3g2Hel2Y2OYG3SGQ962RYuBhZs2fgKmlBqhVnk1CDMS6 eCCNnK4CAspVwg2dceinBwPK/CdRG1SXc70dcvhQtdDGL9CmIBXrsBSF8Gp8KXw5Mu8h wLwbCVurrVjKVWfaTyM8agQjm2zrTJeLKo7lHryGifuRnVjiUmoWWKtoGi3LCQyv3K+T MedVpEvA1wmYU+gJL5oOrQyTijAK5SfWQJNj0bQZVvM7X+XXJd59Gb3tckoVdUbirc6u 5v+A== 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:mime-version:content-transfer-encoding; bh=Lkrlnh41qEla6doz611nE2A+6RV961H8nQhZ4jF0FBc=; b=VVYJUbrTCeUDK9GMcoSkR3hMQeSI+74f28EQv2ICsSBJsH+ux9rs9MZ37yEqvd5n+c ml54Vs+HDr1lavgPhlT6Y3M1tIWVrWa4Feway5A5+Z3CVPLxj4+oGuXboer/iFXYUZiI cH4HujI8i6Yw4yNGWaXN0ksPIMgQ4brv826iW7CPU//NKZynpdGrDO9JiliHua8y4h4j BXGwgGG1SzoVCyPcAUj3BVuGFh9JzYaUMa6HKPwwf0Lpn0FMVbiJ9xwfmRfi59y7Bgq2 Uv/dUBIUxIm3X8mybtp7gzF+kbz+MCj3bUcPrXPxlqskQ2Y4mVAMjgUBl/s6peBJ47aT zuVw== X-Gm-Message-State: ANhLgQ2wwjq294rLZVpiJVwaijt0IuxGpJxFOyKCMenBVRL0FhQ9DQ2U 4H3mvOD6cdu6sPIdSVpUeA== X-Google-Smtp-Source: ADFU+vt26S9CVSgs4QLsmbqlt8QeiFohBL2uesG6RFcE6CR1K8EvKFJsPsZAswdxLzma3hT2RI3ovw== X-Received: by 2002:adf:a489:: with SMTP id g9mr609258wrb.44.1584473546689; Tue, 17 Mar 2020 12:32:26 -0700 (PDT) Received: from avx2.telecom.by ([46.53.254.169]) by smtp.gmail.com with ESMTPSA id t1sm5946323wrq.36.2020.03.17.12.32.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Mar 2020 12:32:25 -0700 (PDT) From: Alexey Dobriyan To: akpm@linux-foundation.org Cc: willy@infradead.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, adobriyan@gmail.com Subject: [PATCH 5/5] proc: inline m_next_vma into m_next Date: Tue, 17 Mar 2020 22:32:01 +0300 Message-Id: <20200317193201.9924-5-adobriyan@gmail.com> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200317193201.9924-1-adobriyan@gmail.com> References: <20200317193201.9924-1-adobriyan@gmail.com> MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org From: "Matthew Wilcox (Oracle)" It's clearer to just put this inline. Signed-off-by: Matthew Wilcox (Oracle) Signed-off-by: Alexey Dobriyan --- fs/proc/task_mmu.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 9f10ef72b839..87641df8c0d0 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -123,14 +123,6 @@ static void release_task_mempolicy(struct proc_maps_private *priv) } #endif -static struct vm_area_struct * -m_next_vma(struct proc_maps_private *priv, struct vm_area_struct *vma) -{ - if (vma == priv->tail_vma) - return NULL; - return vma->vm_next ?: priv->tail_vma; -} - static void *m_start(struct seq_file *m, loff_t *ppos) { struct proc_maps_private *priv = m->private; @@ -173,9 +165,15 @@ static void *m_start(struct seq_file *m, loff_t *ppos) static void *m_next(struct seq_file *m, void *v, loff_t *ppos) { struct proc_maps_private *priv = m->private; - struct vm_area_struct *next; + struct vm_area_struct *next, *vma = v; + + if (vma == priv->tail_vma) + next = NULL; + else if (vma->vm_next) + next = vma->vm_next; + else + next = priv->tail_vma; - next = m_next_vma(priv, v); *ppos = next ? next->vm_start : -1UL; return next;