Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1310318pxa; Sat, 15 Aug 2020 15:24:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5XIQ3F7olt9gH9CIiC7PilXn9AwHN//dp12PgKBlkH0SC4DYYiK5cAaaLUY1shdUTU/qS X-Received: by 2002:a17:906:3f91:: with SMTP id b17mr8132900ejj.165.1597530289743; Sat, 15 Aug 2020 15:24:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597530289; cv=none; d=google.com; s=arc-20160816; b=0j2VAJGKyXt6clUUqvDTDAExVniYQLXftYmMpzqplUtBS+6+k/RvhGnSCi2PiTIFKS Iys6liiP4GgHAE2qzoZqr5phnAJqVLKHRevc7g1RPPxc6H4wOeAd/kjOLt135y/JrEyD duSB8/02U0Fit9ONnAFx88VhqhQUqCeaVudso84Gjm0vPlMiUg/s1/SHTaWnzIJJA4Qh kpGIMte1mjokmndE7coTBE1CNHl7frwHdMJB+NzAPsDuNq3PY+Zy7FNn5zqQQPxlSqUQ pd5GX2UIH2pV36p9/UhLztn5zAFIn8NhjQjzB2oTZZtn+Hrk1F09+38hAO1PqYjJAjfh F6wg== 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=YA4JOsafUu++JjSsQF2E/IhPn4DDh2jo2uC1ikiF7DROZ41s6kwRVtr9sMNbSfkOd0 cgEq5yEvJYca3wfQEa2GFRJesHcNAsbFIRnokzezxftQlpB0UORHYfdttRZhb3oDT1w7 7Faxk7an3yCQGkyulEfMFsebN6nACOlrOhIau9R1q7Ty3+PxdymlXhzFW3Zq3C8aHgtO XvS9d3RvJU1j/9NGBxopKAUTPSLZr2Z5+SgMmU4iXu/23yvt4+o1Fo01HhdbTs1JjYL+ Mr8IiPwG0YBM/bSEIQopNHQJ2LuapPIFu3sh05CL+BN/KzmpiHsAduQVPLU03bGx8Vaq XDwg== 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 jr23si7453070ejb.572.2020.08.15.15.24.27; Sat, 15 Aug 2020 15:24:49 -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 S1729014AbgHOWXw (ORCPT + 99 others); Sat, 15 Aug 2020 18:23:52 -0400 Received: from mx2.suse.de ([195.135.220.15]:37946 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729022AbgHOWXv (ORCPT ); Sat, 15 Aug 2020 18:23:51 -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 C2882AE91; Sat, 15 Aug 2020 07:48:46 +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 2/3] nvme-tcp: check page by sendpage_ok() before calling kernel_sendpage() Date: Sat, 15 Aug 2020 15:48:03 +0800 Message-Id: <20200815074804.46995-2-colyli@suse.de> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200815074804.46995-1-colyli@suse.de> References: <20200815074804.46995-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