Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1534544pxu; Fri, 27 Nov 2020 09:16:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJzfHiojsEOim+ChEp4Qmi4Sz6DciNN+HWkWmw+WIWVaW15LBXn2xV5g+X2DZSgRMtGNUM/h X-Received: by 2002:a05:6402:491:: with SMTP id k17mr8994278edv.370.1606497389998; Fri, 27 Nov 2020 09:16:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606497389; cv=none; d=google.com; s=arc-20160816; b=YXDj2gIqFzNu4zfYXdMbci064c8peQMrGIjcSwiBZkOyopTPDM+R/5xCmZ3lepFkXx nZ8ktD0r+uoGWr3xhun900j9epmgcMIrtuVzeVsBy6MtkxIQ1Pz41QvXqq5tLLMaF98L iVSA9WCT+StJcU8TE6KCU8rq4aI11L+nkeymmt02C3uw1k4xVEj5ucMdBp0Ae6/Sf/MB ZclfZH03Z8vjzpcBE16ZtsI1sNprNMN14j9vUASpGqFOKmgqozxIB+VhsyWojh0eCvmg 8Q9Jbc3kAbBlyTP3VoiHAKt2xUSDJR+/ZjrtFPgJ1IXrT+a305kujscri1KAdOHo7yUi axLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=FXL1bpUlqJXzznp4VClhdwXzrBzm9V/O9XDJM/WBghU=; b=aP/+AEfn2nFjDXn1hMB6KM3TmbEf/oaqgZnuH3VBQP49+TgJptRB4oTDKwvZskH8G+ ggp6WYSQB3KuXQIqw1HmqQ7vgcQ3Dzr+vaWI2Y4kQBEy9Y2oghO1A/S3hcB3NuqHrWA5 dglM6WY5zFsVjT/w497BuTMJAERnduP/X6tA8K2fanZexs4SEJV3mP8NEcamFElbJ7Bw YuSnJPG0VAFb1nh1+7U4iBkXu0EP2pmJU1eANkBwVglGsYBpspnZplSC0M1Vsj0Csb1Q aQPN9ERzD7gSZi5YBzgGzwb37/tsnbfsO7rocMmhBc7oeEDcrZS12JfB3cwe3aQwTOSK +AAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VntZcQrF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 z7si5598619edm.477.2020.11.27.09.16.05; Fri, 27 Nov 2020 09:16:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-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=VntZcQrF; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-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 S1731905AbgK0ROV (ORCPT + 99 others); Fri, 27 Nov 2020 12:14:21 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21524 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731419AbgK0ROU (ORCPT ); Fri, 27 Nov 2020 12:14:20 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1606497260; 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: in-reply-to:in-reply-to:references:references; bh=FXL1bpUlqJXzznp4VClhdwXzrBzm9V/O9XDJM/WBghU=; b=VntZcQrFWBPm+WLG9kwXsxMkOTrpNtVy2I5WOJdDG7Y0qQEpV6EHw4tiBZL3Fn3teh1/Sv tvc70EKGOZmQtYBGyhR4ROYdwe5GoiSXENgAK1MFMSWttcZIaC3jB/ZWU+DxspNCuhH6+n 0dnJcQAxLGrZX6wGBq4SKk+C2oF22Wo= Received: from mail-io1-f70.google.com (mail-io1-f70.google.com [209.85.166.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-203-26hKGkCePgW6T4QwqUZS5Q-1; Fri, 27 Nov 2020 12:14:18 -0500 X-MC-Unique: 26hKGkCePgW6T4QwqUZS5Q-1 Received: by mail-io1-f70.google.com with SMTP id m3so3685503iok.21 for ; Fri, 27 Nov 2020 09:14:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=FXL1bpUlqJXzznp4VClhdwXzrBzm9V/O9XDJM/WBghU=; b=An/tRm9WSBI2mXgYFHKTDgcPnYLyxFwv/80Y/QXiUBcc1JvEnqJoQR+vqmMLqTrHFz 3PIYhE+jSZ0EEfrc8779Gi00gbTfqh+GsHrDzjEk56IawmThM9thJu5n9hSIlVxOz/n2 TaTvOgRN9N06tvAYtxwmn2i0RVNJ/Vb85w7ElwBOL53X14WywLDLU9DqyDrlSj4K4lnG 14VT7uEgF+IBUCFeIL0sVUBVN+fBuNbnha4XMZepaVJ6TmZL6b0ksJ/eKjZ3MeJZ12GY OUg1t5b0/bNeNlaqcx5MLZnBWPpOj18wqqLRhXErpTvImeb8FyembiTRRsyXrQ9Vtwvd xsRQ== X-Gm-Message-State: AOAM531URwVRFcMKffaFw/CovM2Fo7w99mpsP1ZzhcuUOFrRjH+jzbJP NcVtHANi1tJwb/R5L4zBYSqK7dhyYMe06Unkxa73FrQUjfFbrF3pW2zBMBzFH0NQh4RFOXfGPRJ oJ3bWs2LlelWMs5v0DBFiBco7hDTIixSazk5O X-Received: by 2002:a05:6638:f89:: with SMTP id h9mr8383670jal.89.1606497257429; Fri, 27 Nov 2020 09:14:17 -0800 (PST) X-Received: by 2002:a05:6638:f89:: with SMTP id h9mr8383659jal.89.1606497257167; Fri, 27 Nov 2020 09:14:17 -0800 (PST) MIME-Version: 1.0 References: <20201127161451.17922-1-rbergant@redhat.com> In-Reply-To: From: Roberto Bergantinos Corpas Date: Fri, 27 Nov 2020 18:14:04 +0100 Message-ID: Subject: Re: [PATCH] sunrpc: clean-up cache downcall To: Chuck Lever Cc: Bruce Fields , Linux NFS Mailing List Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Hi Bruce! Thanks for comments!, i'll send a v2 with mechanical errors fixed based on v5.10-rc5. rgds roberto On Fri, Nov 27, 2020 at 5:52 PM Chuck Lever wrote: > > Hi Roberto- > > I spotted some mechanical problems. > > > > On Nov 27, 2020, at 11:14 AM, Roberto Bergantinos Corpas wrote: > > > > We can simplifly code around cache_downcall unifying memory > > ^simplifly^simplify > > > allocations using kvmalloc, this have the benefit of getting rid of > > ^, this have^. This has > > > cache_slow_downcall (and queue_io_mutex), and also matches userland > > allocation size and limits > > > > Signed-off-by: Roberto Bergantinos Corpas > > Assuming Bruce is copacetic with this patch, the change looks > appropriate for the v5.11 merge window. However, this patch > doesn't appear to apply to v5.10-rc5. Might be because > 27a1e8a0f79e ("sunrpc: raise kernel RPC channel buffer size") > was already merged? > > > > --- > > net/sunrpc/cache.c | 41 +++++++++++------------------------------ > > 1 file changed, 11 insertions(+), 30 deletions(-) > > > > diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c > > index baef5ee43dbb..1347ecae9c84 100644 > > --- a/net/sunrpc/cache.c > > +++ b/net/sunrpc/cache.c > > @@ -777,7 +777,6 @@ void cache_clean_deferred(void *owner) > > */ > > > > static DEFINE_SPINLOCK(queue_lock); > > -static DEFINE_MUTEX(queue_io_mutex); > > > > struct cache_queue { > > struct list_head list; > > @@ -905,44 +904,26 @@ static ssize_t cache_do_downcall(char *kaddr, const char __user *buf, > > return ret; > > } > > > > -static ssize_t cache_slow_downcall(const char __user *buf, > > - size_t count, struct cache_detail *cd) > > -{ > > - static char write_buf[8192]; /* protected by queue_io_mutex */ > > - ssize_t ret = -EINVAL; > > - > > - if (count >= sizeof(write_buf)) > > - goto out; > > - mutex_lock(&queue_io_mutex); > > - ret = cache_do_downcall(write_buf, buf, count, cd); > > - mutex_unlock(&queue_io_mutex); > > -out: > > - return ret; > > -} > > - > > static ssize_t cache_downcall(struct address_space *mapping, > > const char __user *buf, > > size_t count, struct cache_detail *cd) > > { > > - struct page *page; > > - char *kaddr; > > + char *write_buf; > > ssize_t ret = -ENOMEM; > > > > - if (count >= PAGE_SIZE) > > - goto out_slow; > > + if (count >= 32768) { /* 32k is max userland buffer, lets check anyway */ > > + ret = -EINVAL; > > + goto out; > > + } > > > > - page = find_or_create_page(mapping, 0, GFP_KERNEL); > > - if (!page) > > - goto out_slow; > > + write_buf = kvmalloc(count + 1, GFP_KERNEL); > > + if (!write_buf) > > + goto out; > > > > - kaddr = kmap(page); > > - ret = cache_do_downcall(kaddr, buf, count, cd); > > - kunmap(page); > > - unlock_page(page); > > - put_page(page); > > + ret = cache_do_downcall(write_buf, buf, count, cd); > > + kvfree(write_buf); > > +out: > > return ret; > > -out_slow: > > - return cache_slow_downcall(buf, count, cd); > > } > > > > static ssize_t cache_write(struct file *filp, const char __user *buf, > > -- > > 2.21.0 > > > > -- > Chuck Lever > > >