Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2964959imu; Mon, 17 Dec 2018 10:43:52 -0800 (PST) X-Google-Smtp-Source: AFSGD/UCse5RlloVVLZd13xioqLBqvFJ7u/tebIrGkA2xUJYtqQpcEjoKVEalQIWQfbJnMhg1zcI X-Received: by 2002:a62:3141:: with SMTP id x62mr13690730pfx.12.1545072232752; Mon, 17 Dec 2018 10:43:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545072232; cv=none; d=google.com; s=arc-20160816; b=V/1dMi32SFPvzv8rOQ95ktpHLOU7wyuWEQIafN4EusqAeXXWqdg4BdmpkoyExNL/AT JpWncl2cypo0FR1kmcVX8eN1MPJMOxUnoiSGEDs22TJTx0zUE1wUA95E0Rhk/kRRF+A7 Iz8v2RlnR7XF7JLGg1mUu2T85FtRskJXJAEh1u0Aj4HMQ6ZijdHr8Kjga6cZF+zY9coC 93nZJ+vsrZmv5j5HiJ26Q/dkeGoAcd/gs7MKeWu9pm/gvMTPPJDN5zu2ntQNL3DKMMSm kaU7l779YmFETO0MrncJwUxJEf3TzC6uQbaQIRPpkAmbn+Moo1f7gV2kEpezqTFPrb3e glIg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature; bh=iPxGzNvUbpYdaGSMVmTlfEnk5MteCI7PrIFhmPFOTcs=; b=QIG6RROzegondzPfgS4SO3i8ciJ0vd9hiiGIhjtkzslezx0SYz3qABlaZVY9GxoNo4 JWYpVfMQ+Mk7tlTPudbgVopkT3g2Zi/pD3NIECko1Qhy+oXCOae0xeI873kDP/CHbpmH jwXo4xP3OtS6vVffP0YCYpkD6raBEVXEFt0HXITOfIDV/x9/QvH4L5oKWjbMambqwqFx afSKyUVvfNRYaIh8I3Lqbjjvxg5ffqBrOWOROxMj4AHIPgdORI3Wj0eBv5MdNpYVjkL5 q4T3A38Mv+mLm+ozmld73HRMcPUWSS94WQ0/pry2fAV8cZGiXQdO6IjxqcLUGLNiYZ5T mL1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EMSK6tqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si8571420pll.271.2018.12.17.10.43.37; Mon, 17 Dec 2018 10:43:52 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=EMSK6tqk; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732727AbeLQOm7 (ORCPT + 99 others); Mon, 17 Dec 2018 09:42:59 -0500 Received: from mail-wm1-f66.google.com ([209.85.128.66]:54846 "EHLO mail-wm1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726574AbeLQOm7 (ORCPT ); Mon, 17 Dec 2018 09:42:59 -0500 Received: by mail-wm1-f66.google.com with SMTP id a62so12598256wmh.4 for ; Mon, 17 Dec 2018 06:42:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=iPxGzNvUbpYdaGSMVmTlfEnk5MteCI7PrIFhmPFOTcs=; b=EMSK6tqkxYJ4tFea5J7R6n7kYsK3tOxhuRWVlsDvANbFJrpdi9M6seTsNF/HieNAhu iQ+gzyEB8EhrZXeol0b4rRCYaiglzTM6YxBmSp8Id8a1Rh4UklAlJT4wgLThxVePD6oM SRjb8JkNLx/R1UgtMmveNhVcLLZkNJtrDdzVzjX1BTTm6utRQSad8gNA+nteYKbKDVNn RhB7Xk+9UvTaJZVlTpmGavX3DZxvsTeywRtlm+gzAPQHYoVcYQPBz9rf77bVZgWXvRkl 3JRaf4vQzufbF14anljBwwMCpHDIt0BSNHZoAMngSPEY6BvCsRh19aA+g0ykn1MT/ltG vpfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=iPxGzNvUbpYdaGSMVmTlfEnk5MteCI7PrIFhmPFOTcs=; b=H5hCcKHUNtCkUrMnp25jJMWmn3fTmT33EPYvs52VQXJ5Iuae/b8ld7Cm81FM1fB6Bj mAht4nTvlOAEBGp8s+cuWfpGKDnsdXMgCZKNeQ4XHnEWXTZWa2BWpkvQkTFH3LqITeQq +25cQDx/NKnneCzKUeQ+uiSBSArfWBq+/4dagW0C4I859QjYQEtY8wVJ06nspmjjHiJ4 ABkQiZN8sU4sb9mgRP0azjmyTk1j7M1z+t+zCMMD2r6lJt4AsMh3jkkRPCWkT5gU/3UL iFQLPz8wjvpFNYOvbDDbuWnWby1gi8i1AeqbuVz5KoY7rRPA2H37E5Bm9fFc9IGwebO+ 9p+A== X-Gm-Message-State: AA+aEWbx0abvhjbv1hXSFWcd99QNv9HqU3fszlFeW+iyaVEcgBdLqyy3 J47rXs4jthMuB3ZcxO+qMjc= X-Received: by 2002:a1c:58ce:: with SMTP id m197mr12506247wmb.31.1545057775817; Mon, 17 Dec 2018 06:42:55 -0800 (PST) Received: from [192.168.8.147] (76.42.136.77.rev.sfr.net. [77.136.42.76]) by smtp.gmail.com with ESMTPSA id f130sm11705291wme.41.2018.12.17.06.42.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Dec 2018 06:42:54 -0800 (PST) Subject: Re: [PATCH] iov_iter: optimize page_copy_sane() To: Eric Dumazet , linux-kernel Cc: Eric Dumazet , Al Viro References: <20181208133735.245799-1-edumazet@google.com> From: Eric Dumazet Message-ID: <0d6058b9-8123-6d8c-0571-6ea9a5cd822d@gmail.com> Date: Mon, 17 Dec 2018 06:42:50 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20181208133735.245799-1-edumazet@google.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/08/2018 05:37 AM, Eric Dumazet wrote: > Avoid cache line miss dereferencing struct page if we can. > > page_copy_sane() mostly deals with order-0 pages. > > Signed-off-by: Eric Dumazet > Cc: Al Viro > --- > lib/iov_iter.c | 14 ++++++++++++-- > 1 file changed, 12 insertions(+), 2 deletions(-) > > diff --git a/lib/iov_iter.c b/lib/iov_iter.c > index 54c248526b55fc498c996f2a5ea651262fcc7f61..2a1e282c3d38e2d03b075f54b7f9313e48b90289 100644 > --- a/lib/iov_iter.c > +++ b/lib/iov_iter.c > @@ -854,8 +854,18 @@ EXPORT_SYMBOL(_copy_from_iter_full_nocache); > > static inline bool page_copy_sane(struct page *page, size_t offset, size_t n) > { > - struct page *head = compound_head(page); > - size_t v = n + offset + page_address(page) - page_address(head); > + struct page *head; > + size_t v = n + offset; > + > + /* > + * Fast path if this is an order-0 page, > + * or if the copied area fits the first page of a compound one. > + */ > + if (likely(n <= v && v <= PAGE_SIZE)) > + return true; > + > + head = compound_head(page); > + v += (page - head) << PAGE_SHIFT; > > if (likely(n <= v && v <= (PAGE_SIZE << compound_order(head)))) > return true; > Hi Alexander ! Any news on this patch ? Thanks !