Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2264089imm; Thu, 7 Jun 2018 07:55:25 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKGZENxsi6dq0R9xFFR2kUBXD50ClEjDZIG1B20PF18lqWxkP4Vqcjn+YrORFeW7R2jOBeZ X-Received: by 2002:a63:980a:: with SMTP id q10-v6mr1862855pgd.50.1528383325792; Thu, 07 Jun 2018 07:55:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528383325; cv=none; d=google.com; s=arc-20160816; b=H6EkajpvXe5JkEk0Hq5Jv1g+4bBTDN9reoFLT20NTCYTbJAKWhOkDLLHAIXVhh4VcO /xpWGMBKIOD881qWizHXcj0lCm3CbpnV+r6ZQCYnSUwPwDERIyfPTo+HgkzTTHtwJFB/ AGrXDY5sHxC/H941sBvwjp0sVKP48lvwHvnap418CYeRnRfY1m95cIaDG+6fJhkAzdwd IzzP4UNff2+ex0QiQdr2zf9f4bcbTtVEBQ0JEkAZ45sI4vgtHEFNeV6V3mz5CmMMBdMs XK85pkn5Z0XnkKTaVwwaTQyeFrnlXaBDAOUiDHkkonnhZdIDRLHHvd2kug6ADZJpIGZQ 8+4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=u2ZsRTwWTwOLI5kxzwcWeoUccaUZAgOcJD3hKGh0a8Y=; b=BUeYMeG+tF21S51EgmRezzuoi4zGmhIDNZ6coQyZam3/1fL0q6+iwlDJpnwvHO1Mxk +q+inOPpqDgs86JBM0uh75wKulrjrAKOPs4B8AEs6wBRiFgFF5sia1TRrfALwAicMYyt 6juCep5l5hTsVnY5xEOtLtLgIWMxe/XSMEDUwHqNqmSKMtMXHW5kyDPWoqrbk+r48+jB kVTSWYRvg7ZeX08Tilo0JOWBiIQnlA26rehNnzhIf4Ai3JU9NuLxgAAgAiJYekUKMYtr w/eTuqp7yITLRPwssh+yUpZJtmajHtKt6oID6eC3QcDfFQSFKBS1+4WA522Vfx5SZQ+U cD9g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x65-v6si16883512pgb.598.2018.06.07.07.55.11; Thu, 07 Jun 2018 07:55:25 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935341AbeFGOyI (ORCPT + 99 others); Thu, 7 Jun 2018 10:54:08 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:40978 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935307AbeFGOyF (ORCPT ); Thu, 7 Jun 2018 10:54:05 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbg-0005dI-H8; Thu, 07 Jun 2018 15:09:40 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvb5-0002zY-Ux; Thu, 07 Jun 2018 15:09:03 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "Jens Axboe" , "" , "Al Viro" , "Willy Tarreau" , "Michael Kerrisk (man-pages)" , "Vegard Nossum" , "Tetsuo Handa" , "Linus Torvalds" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 201/410] pipe: refactor argument for account_pipe_buffers() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "Michael Kerrisk (man-pages)" commit 3734a13b96ebf039b293d8d37a934fd1bd9e03ab upstream. This is a preparatory patch for following work. account_pipe_buffers() performs accounting in the 'user_struct'. There is no need to pass a pointer to a 'pipe_inode_info' struct (which is then dereferenced to obtain a pointer to the 'user' field). Instead, pass a pointer directly to the 'user_struct'. This change is needed in preparation for a subsequent patch that the fixes the limit checking in alloc_pipe_info() (and the resulting code is a little more logical). Link: http://lkml.kernel.org/r/7277bf8c-a6fc-4a7d-659c-f5b145c981ab@gmail.com Signed-off-by: Michael Kerrisk Reviewed-by: Vegard Nossum Cc: Willy Tarreau Cc: Cc: Tetsuo Handa Cc: Jens Axboe Cc: Al Viro Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- fs/pipe.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) --- a/fs/pipe.c +++ b/fs/pipe.c @@ -590,10 +590,10 @@ pipe_fasync(int fd, struct file *filp, i return retval; } -static void account_pipe_buffers(struct pipe_inode_info *pipe, +static void account_pipe_buffers(struct user_struct *user, unsigned long old, unsigned long new) { - atomic_long_add(new - old, &pipe->user->pipe_bufs); + atomic_long_add(new - old, &user->pipe_bufs); } static bool too_many_pipe_buffers_soft(struct user_struct *user) @@ -628,7 +628,7 @@ struct pipe_inode_info *alloc_pipe_info( pipe->r_counter = pipe->w_counter = 1; pipe->buffers = pipe_bufs; pipe->user = user; - account_pipe_buffers(pipe, 0, pipe_bufs); + account_pipe_buffers(user, 0, pipe_bufs); mutex_init(&pipe->mutex); return pipe; } @@ -643,7 +643,7 @@ void free_pipe_info(struct pipe_inode_in { int i; - account_pipe_buffers(pipe, pipe->buffers, 0); + account_pipe_buffers(pipe->user, pipe->buffers, 0); free_uid(pipe->user); for (i = 0; i < pipe->buffers; i++) { struct pipe_buffer *buf = pipe->bufs + i; @@ -1062,7 +1062,7 @@ static long pipe_set_size(struct pipe_in memcpy(bufs + head, pipe->bufs, tail * sizeof(struct pipe_buffer)); } - account_pipe_buffers(pipe, pipe->buffers, nr_pages); + account_pipe_buffers(pipe->user, pipe->buffers, nr_pages); pipe->curbuf = 0; kfree(pipe->bufs); pipe->bufs = bufs;