From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.3 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABA8FC2BA83 for ; Thu, 13 Feb 2020 16:55:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 6E4BB206ED for ; Thu, 13 Feb 2020 16:55:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="DHGr2qve" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 6E4BB206ED Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 095836B0579; Thu, 13 Feb 2020 11:55:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 047A86B057B; Thu, 13 Feb 2020 11:55:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9FC86B057C; Thu, 13 Feb 2020 11:55:41 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0196.hostedemail.com [216.40.44.196]) by kanga.kvack.org (Postfix) with ESMTP id D3C346B0579 for ; Thu, 13 Feb 2020 11:55:41 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 84AB6180AD804 for ; Thu, 13 Feb 2020 16:55:41 +0000 (UTC) X-FDA: 76485705282.07.tax98_88ec904c0ea3e X-HE-Tag: tax98_88ec904c0ea3e X-Filterd-Recvd-Size: 6631 Received: from mail-wm1-f66.google.com (mail-wm1-f66.google.com [209.85.128.66]) by imf34.hostedemail.com (Postfix) with ESMTP for ; Thu, 13 Feb 2020 16:55:40 +0000 (UTC) Received: by mail-wm1-f66.google.com with SMTP id q9so7038618wmj.5 for ; Thu, 13 Feb 2020 08:55:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cDryonWZY2uim0kUcOdklU9kJxiT6lt/ZLusCbe9Vu0=; b=DHGr2qvezyDarMsNQHvPJBLE9+ZuhDdSi66fIAK7hnupVSI08lkphHNhKwGXlGtDng ZIW3yijKM8BA11jRT3oIQouP9KLJcP/rzsa89VOqFsZVxrYb3j8kIKKjRfAe+1SzgTox yRHxT/V7m1/15NG+O2Rf3fJWH16LNIEaRZVQW7OCHTet9wCxvtJcCU5bFdo9OIdZRD2D pqanPcXYCSOH8XMF8mkKtQvqY8gNTBLTXQRNwJWQj34fZZYu3CaQDxcxbj9V82Gxw+dw wB6AGrsPZJ5o0VNtvR12DotsuoKxo5P7ATxQnTPlxpRD6NdaUvT/PssRXGc/ehVdCEQr rA4w== 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=cDryonWZY2uim0kUcOdklU9kJxiT6lt/ZLusCbe9Vu0=; b=Rc/02YHJiXcIoA0Yo9CLlLfQa11dFc8QKy9WXqFQ0luRQZYgRRl6s9j1QAQTgRyZOE nPYF1YhUMhhWIOmqAxkPbxmmxHOr+rM45SgmHtEq8kOhA8IfLfPm4rTs5c/aunv5EC+J Iumk6vZQhZmF9FPLDmjs5yhfVw255NQNfAh59OZN4p0WICU/mqxYoRdTpJPOATjXAeIF bjMLksCrOKeDG+FjngPRoGUM8YCkIKUsnjeWJVrNnFsbshJKbBy08JbkZNDYP41LyyZO vIVSoQZz18l5SAuCpG5aMi4OY0DpMuu15/2SvNgbo0xej38SLwICBc+aqOLpagJrbNQ6 uolg== X-Gm-Message-State: APjAAAXyCswSGBpNE1+3DEeYwyaWWVGBDxW4equzXCzPAep5LCMSLa90 vAJuM7En5+OPbyOCjZMygbjA6jbak/sg24/43wmGlA== X-Google-Smtp-Source: APXvYqwimIhKs4gIgr9ijKaFK6snXU78BQ5LHnIoORhGIghYDeqh0awPtRevCb3gABPCKCXE2inQMFbtysaRKXpqTMY= X-Received: by 2002:a1c:4857:: with SMTP id v84mr6719784wma.8.1581612939441; Thu, 13 Feb 2020 08:55:39 -0800 (PST) MIME-Version: 1.0 References: <20200128025958.43490-1-arjunroy.kdev@gmail.com> <20200212184115.127c17c6b0f9dab6fcae56c2@linux-foundation.org> In-Reply-To: <20200212184115.127c17c6b0f9dab6fcae56c2@linux-foundation.org> From: Arjun Roy Date: Thu, 13 Feb 2020 08:55:28 -0800 Message-ID: Subject: Re: [PATCH resend mm,net-next 1/3] mm: Refactor insert_page to prepare for batched-lock insert. To: Andrew Morton Cc: Arjun Roy , davem@davemloft.net, netdev@vger.kernel.org, linux-mm@kvack.org, Eric Dumazet , Soheil Hassas Yeganeh Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The addition of page_has_type() looks good to me, thanks! -Arjun On Wed, Feb 12, 2020 at 6:41 PM Andrew Morton wrote: > > On Mon, 27 Jan 2020 18:59:56 -0800 Arjun Roy wrote: > > > Add helper methods for vm_insert_page()/insert_page() to prepare for > > vm_insert_pages(), which batch-inserts pages to reduce spinlock > > operations when inserting multiple consecutive pages into the user > > page table. > > > > The intention of this patch-set is to reduce atomic ops for > > tcp zerocopy receives, which normally hits the same spinlock multiple > > times consecutively. > > I tweaked this a bit for the addition of page_has_type() to > insert_page(). Please check. > > > > From: Arjun Roy > Subject: mm: Refactor insert_page to prepare for batched-lock insert. > > From: Arjun Roy > > Add helper methods for vm_insert_page()/insert_page() to prepare for > vm_insert_pages(), which batch-inserts pages to reduce spinlock > operations when inserting multiple consecutive pages into the user > page table. > > The intention of this patch-set is to reduce atomic ops for > tcp zerocopy receives, which normally hits the same spinlock multiple > times consecutively. > > Link: http://lkml.kernel.org/r/20200128025958.43490-1-arjunroy.kdev@gmail.com > Signed-off-by: Arjun Roy > Signed-off-by: Eric Dumazet > Signed-off-by: Soheil Hassas Yeganeh > > Signed-off-by: Andrew Morton > --- > > mm/memory.c | 39 ++++++++++++++++++++++++--------------- > 1 file changed, 24 insertions(+), 15 deletions(-) > > --- a/mm/memory.c~mm-refactor-insert_page-to-prepare-for-batched-lock-insert > +++ a/mm/memory.c > @@ -1430,6 +1430,27 @@ pte_t *__get_locked_pte(struct mm_struct > return pte_alloc_map_lock(mm, pmd, addr, ptl); > } > > +static int validate_page_before_insert(struct page *page) > +{ > + if (PageAnon(page) || PageSlab(page) || page_has_type(page)) > + return -EINVAL; > + flush_dcache_page(page); > + return 0; > +} > + > +static int insert_page_into_pte_locked(struct mm_struct *mm, pte_t *pte, > + unsigned long addr, struct page *page, pgprot_t prot) > +{ > + if (!pte_none(*pte)) > + return -EBUSY; > + /* Ok, finally just insert the thing.. */ > + get_page(page); > + inc_mm_counter_fast(mm, mm_counter_file(page)); > + page_add_file_rmap(page, false); > + set_pte_at(mm, addr, pte, mk_pte(page, prot)); > + return 0; > +} > + > /* > * This is the old fallback for page remapping. > * > @@ -1445,26 +1466,14 @@ static int insert_page(struct vm_area_st > pte_t *pte; > spinlock_t *ptl; > > - retval = -EINVAL; > - if (PageAnon(page) || PageSlab(page) || page_has_type(page)) > + retval = validate_page_before_insert(page); > + if (retval) > goto out; > retval = -ENOMEM; > - flush_dcache_page(page); > pte = get_locked_pte(mm, addr, &ptl); > if (!pte) > goto out; > - retval = -EBUSY; > - if (!pte_none(*pte)) > - goto out_unlock; > - > - /* Ok, finally just insert the thing.. */ > - get_page(page); > - inc_mm_counter_fast(mm, mm_counter_file(page)); > - page_add_file_rmap(page, false); > - set_pte_at(mm, addr, pte, mk_pte(page, prot)); > - > - retval = 0; > -out_unlock: > + retval = insert_page_into_pte_locked(mm, pte, addr, page, prot); > pte_unmap_unlock(pte, ptl); > out: > return retval; > _ >