From patchwork Fri Feb 14 00:59:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Roy X-Patchwork-Id: 11381491 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 8902A1395 for ; Fri, 14 Feb 2020 00:59:36 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 53963222C4 for ; Fri, 14 Feb 2020 00:59:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UgvQLtGA" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 53963222C4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 6F2256B05CA; Thu, 13 Feb 2020 19:59:35 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6A2F76B05CB; Thu, 13 Feb 2020 19:59:35 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 592C06B05CC; Thu, 13 Feb 2020 19:59:35 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0151.hostedemail.com [216.40.44.151]) by kanga.kvack.org (Postfix) with ESMTP id 3D8C06B05CA for ; Thu, 13 Feb 2020 19:59:35 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id E9C92824805A for ; Fri, 14 Feb 2020 00:59:34 +0000 (UTC) X-FDA: 76486924668.19.cows90_8dd20982f3e13 X-Spam-Summary: 50,0,0,70df3d1aa3a8bb8b,d41d8cd98f00b204,arjunroy.kdev@gmail.com,:davem@davemloft.net:netdev@vger.kernel.org:akpm@linux-foundation.org::arjunroy@google.com:soheil@google.com:edumazet@google.com,RULES_HIT:41:196:355:379:541:800:960:967:973:988:989:1260:1311:1314:1345:1431:1437:1515:1534:1541:1622:1711:1730:1747:1777:1792:2393:2525:2560:2563:2682:2685:2859:2933:2937:2939:2942:2945:2947:2951:2954:3022:3138:3139:3140:3141:3142:3352:3865:3866:3867:3870:3871:3934:3936:3938:3941:3944:3947:3950:3953:3956:3959:4321:5007:6119:6261:6653:6671:7576:9025:9413:10004:11026:11658:11914:12043:12048:12296:12297:12438:12517:12519:12555:12679:12895:12986:13007:13069:13161:13229:13311:13357:13894:14096:14181:14384:14394:14687:14721:21080:21444:21451:21627:21666:21990:30054:30070,0,RBL:209.85.215.195:@gmail.com:.lbl8.mailshell.net-62.18.0.100 66.100.201.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtim e:24,LUA X-HE-Tag: cows90_8dd20982f3e13 X-Filterd-Recvd-Size: 4063 Received: from mail-pg1-f195.google.com (mail-pg1-f195.google.com [209.85.215.195]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Fri, 14 Feb 2020 00:59:34 +0000 (UTC) Received: by mail-pg1-f195.google.com with SMTP id z7so4046181pgk.7 for ; Thu, 13 Feb 2020 16:59:34 -0800 (PST) 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=varpYZ4e9HN4fOkt9AtUu2Zz+YP3IR3moNk2yDZcybk=; b=UgvQLtGAB7MtuSvb5VW5iX6JP4xMoRNI1OFPG2iOs+jBYmJ+WbXDLlC4AjJiw9wCv0 F+sqYSnaOv8wS1gVLx325xQ4ryuIrHQ+2jyPELmBAqwHTgtsnX5rdCJVJ8/inT6Vi81l O+bZNZ2gn6fq/dtslTf7kEKAONzoRa30zdfjs9JMzix9yP0WsrRw6bk0ZiCqdtKTZ4qg USl12yzLNmB1Y9U4NqiQI6DtrC2ulOFYhSjsJWL8BGxtdxsO5vexuc0ug5C7GRfwq5bE sL+zf0Lx82VBMzHwEpo6sRl8R/fuE1E1IIYhgyjdmMhc1X4s4zhz9T6dJzcRJEl6ZoS/ Q6ww== 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=varpYZ4e9HN4fOkt9AtUu2Zz+YP3IR3moNk2yDZcybk=; b=umBIMTbFPMsrb+S9WaOezkJawuSqwGcteJi9W90QgI/66uDQiYoWNNgwlpk1BDwHOU 8r0AEkg2DHBj0mAFjUOhioutSPQ/DR1H9M8dZfb9ceR3Tq2DmZ1+Bk8T2cpAXK3sllQX zlzuI1D6F7/+TxCt6RzVnJPPXb/X1LGbsPklyKVVA1arDqjZJ9lIsllQDlLhvPkDtl1X lgX9FQgOukTjM5E9N5ZktPwZry8gBOzEZlHWifIe4V9QM+6+KPHC9tHbO0pTf+jb8uVa 3UbJh1gnbL2yTDfHSHRtDWnq2pGKI2nMcJ+AhUah9tD1fDJPe2ngmq5JI4Ede4GGIyFS SEbw== X-Gm-Message-State: APjAAAXJmbSxK4AwZCASxpAZexKsaC8TH0bMNj90wdK7ZwtdaaCbMu73 0Cal1YdK+uqqHr4QiztbQLk= X-Google-Smtp-Source: APXvYqwyr+txoEK8I+6o4JJ357eA8FoNm7+oeZf4aoBqqZq7gyiUnYPml18ZWdiN7zEcdkSoova6Tg== X-Received: by 2002:a62:8e0a:: with SMTP id k10mr636956pfe.49.1581641973348; Thu, 13 Feb 2020 16:59:33 -0800 (PST) Received: from phantasmagoria.svl.corp.google.com ([2620:15c:2c4:201:2b0a:8c1:6a84:1aa0]) by smtp.gmail.com with ESMTPSA id e6sm4412759pfh.32.2020.02.13.16.59.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Feb 2020 16:59:32 -0800 (PST) From: Arjun Roy To: davem@davemloft.net, netdev@vger.kernel.org, akpm@linux-foundation.org, linux-mm@kvack.org Cc: arjunroy@google.com, soheil@google.com, edumazet@google.com Subject: [PATCH mm, next-next] Add missing page_count() check to vm_insert_pages(). Date: Thu, 13 Feb 2020 16:59:29 -0800 Message-Id: <20200214005929.104481-1-arjunroy.kdev@gmail.com> X-Mailer: git-send-email 2.25.0.265.gbab2e86ba0-goog MIME-Version: 1.0 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000023, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Arjun Roy Add missing page_count() check to vm_insert_pages(), specifically inside insert_page_in_batch_locked(). This was accidentally forgotten in the original patchset. See: https://marc.info/?l=linux-mm&m=158156166403807&w=2 The intention of this patch-set is to reduce atomic ops for tcp zerocopy receives, which normally hits the same spinlock multiple times consecutively. Signed-off-by: Arjun Roy --- mm/memory.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mm/memory.c b/mm/memory.c index f1d5f2264aef..3b4007a6ef7f 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -1463,8 +1463,11 @@ static int insert_page_into_pte_locked(struct mm_struct *mm, pte_t *pte, static int insert_page_in_batch_locked(struct mm_struct *mm, pmd_t *pmd, unsigned long addr, struct page *page, pgprot_t prot) { - const int err = validate_page_before_insert(page); + int err; + if (!page_count(page)) + return -EINVAL; + err = validate_page_before_insert(page); return err ? err : insert_page_into_pte_locked( mm, pte_offset_map(pmd, addr), addr, page, prot); }