Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1523902pxa; Sun, 16 Aug 2020 01:23:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwMq4OaKwQUmh0x258SOVlsRJ1alVunhjxTigXo6bqdid3gDvvJ9lnzXuNRENIP3nCFvphj X-Received: by 2002:a17:906:4e14:: with SMTP id z20mr10331076eju.541.1597566223680; Sun, 16 Aug 2020 01:23:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597566223; cv=none; d=google.com; s=arc-20160816; b=aCkau6MaBTktT7FdY32dczDBInVgwa4AaAJUxuHPYBdPr8Hw/Uv9ZFMuAH++PZ0V61 gmOWhLZgJPXmI76ANjUGsw4j4xnOJZ3F9GuSidaKkJQHexDLic0DBJvYnS2d+C3IGtxg eMoirw0sIICPbuOJrsTXFvguAZ16skMZsa52Pw7uqniS6Ns+e4eojvLkarWXi9x2MbWD wwjOpzy+dG0aJwN83OUTe/+aVd3lu696GSv3Ibjz3+toNUzAitxAz/GAXDQNkyEFWkGm pmUHCKhMU0su/Z8j8R0rJO95CAq445doLAbnCUKyKTESEPrzjXzv344WJcO650havKVB Jueg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=u6lh5LWsmSTqi9Ds5pCl9l4eR+3garWymWsPWK5d4Yk=; b=ZdQpg4+rOND4qgw+VLGaAMPB9MtQH2hxk2ioVej8JsPMySzw0NY46b9o4qXOnWl2Jm +ianLR+MRV7tbQ0d8wi3ZuVpTyyqpzB4aYg5tBWwltkbrP3BQJguqfWoxV4i31qH2LND AJRe4Kd/E8QLPWMxkcReq323Z+z0FIix0dPR1szPKGy2CBCwicl6uemf5LUjRiylzqm4 22vDvsexTfi1+bqIhZC9EephmEG5AEhRSAMBZpWgbql7G3X0/wlN48wtfaTlALCMTxl0 UwCmzaNskDxXwwy4FZn1BPftnbTrOGJxJKJYkdu7YrC8RVokmjoq8o/cdY+uCHEllitn jN9Q== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qc16si8464951ejb.746.2020.08.16.01.23.21; Sun, 16 Aug 2020 01:23:43 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730165AbgHPHIf (ORCPT + 99 others); Sun, 16 Aug 2020 03:08:35 -0400 Received: from mx2.suse.de ([195.135.220.15]:58252 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbgHPHIc (ORCPT ); Sun, 16 Aug 2020 03:08:32 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 46C5AB14D; Sun, 16 Aug 2020 07:08:55 +0000 (UTC) From: Coly Li To: linux-block@vger.kernel.org, linux-nvme@lists.infradead.org Cc: netdev@vger.kernel.org, stable@vger.kernel.org, linux-kernel@vger.kernel.org, Coly Li , Chaitanya Kulkarni , Christoph Hellwig , Hannes Reinecke , Jan Kara , Jens Axboe , Mikhail Skorzhinskii , Philipp Reisner , Sagi Grimberg , Vlastimil Babka Subject: [PATCH v5 2/3] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Date: Sun, 16 Aug 2020 15:08:13 +0800 Message-Id: <20200816070814.6806-2-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200816070814.6806-1-colyli@suse.de> References: <20200816070814.6806-1-colyli@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently nvme_tcp_try_send_data() doesn't use kernel_sendpage() to send slab pages. But for pages allocated by __get_free_pages() without __GFP_COMP, which also have refcount as 0, they are still sent by kernel_sendpage() to remote end, this is problematic. The new introduced helper sendpage_ok() checks both PageSlab tag and page_count counter, and returns true if the checking page is OK to be sent by kernel_sendpage(). This patch fixes the page checking issue of nvme_tcp_try_send_data() with sendpage_ok(). If sendpage_ok() returns true, send this page by kernel_sendpage(), otherwise use sock_no_sendpage to handle this page. Signed-off-by: Coly Li Cc: Chaitanya Kulkarni Cc: Christoph Hellwig Cc: Hannes Reinecke Cc: Jan Kara Cc: Jens Axboe Cc: Mikhail Skorzhinskii Cc: Philipp Reisner Cc: Sagi Grimberg Cc: Vlastimil Babka Cc: stable@vger.kernel.org --- drivers/nvme/host/tcp.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 62fbaecdc960..902fe742762b 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -912,12 +912,11 @@ static int nvme_tcp_try_send_data(struct nvme_tcp_request *req) else flags |= MSG_MORE | MSG_SENDPAGE_NOTLAST; - /* can't zcopy slab pages */ - if (unlikely(PageSlab(page))) { - ret = sock_no_sendpage(queue->sock, page, offset, len, + if (sendpage_ok(page)) { + ret = kernel_sendpage(queue->sock, page, offset, len, flags); } else { - ret = kernel_sendpage(queue->sock, page, offset, len, + ret = sock_no_sendpage(queue->sock, page, offset, len, flags); } if (ret <= 0) -- 2.26.2