Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1278608pxk; Fri, 18 Sep 2020 08:21:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIdaFQU1kpKzpUcTqrz3WOqSlv4e/xsZml30NTKNYSYO2yAbrGCCdSeRle4FhcJDF28DAK X-Received: by 2002:a05:6402:1593:: with SMTP id c19mr39264881edv.33.1600442507637; Fri, 18 Sep 2020 08:21:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600442507; cv=none; d=google.com; s=arc-20160816; b=e3piQKSnORNn9vOLBkPnXnaREitpBzuR5JeYrZR0NQPa4qlM43WR5FF0tegN+3ra50 uV4FN58niU4i7Po+hOgPSVlYRt46Ezs3pP6/am+IA136gF78T0vQePpWJXgoYTRiKzV+ yHw0rSXhk2iG/B2+o2t6BUgjpVBp4vbLjY7k2jPvvx5nWixgRXTpztQ1muQn6zQzWhfn 5aA5GyQ2sDY85+2aPTtATHr9dnXi8SRP54oP3noGAupGzNami6sd7nm7x3HwqUI/Qbqu bff3SWI3s+ezWeYlDCkWhJ9hxMUYo/NAh6oJjHsVmk3ZWXgxxqZ/SeaikpyWtfanS4Vr +ABg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=8ETZHh7FXeQbyxpDjZYV13SKWV6kJy3ncbq86WYzI9Q=; b=EfvfvoWL4I886O6V/GQ1rBkyHaMXN++MhGvCnLtcz/NB7uzmIxe5gCMKnQKBvWcnhH Lp/pAdjKw0dVWOhkisebuOSetFtgOvpbrJUjKTLdRCgbaiv12uQWbGSc8W/yLCT+JJr8 75Ig80kAeI1Ed8RV1WRddmVyXvoPunWCnCl4PEfkz59nqHmenujvagXEFIgihvZZLjdL PVGWvGRr2Wt0GEYt5ZfWJaFpNvh2+aX/n/oGkJM1IriIPbkSHBcUToy/HJGCqMbfdokf 9UUgXg8uIY7wJGfnmX/9L6CwmtVNs+Tr0yUy01UKEYFjX2LQ3AckreQrDMTC/wICa/gH 21dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eFpw96Zb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a26si2319449ejv.698.2020.09.18.08.21.24; Fri, 18 Sep 2020 08:21:47 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=eFpw96Zb; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726200AbgIRPSi (ORCPT + 99 others); Fri, 18 Sep 2020 11:18:38 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:25058 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726044AbgIRPSi (ORCPT ); Fri, 18 Sep 2020 11:18:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1600442316; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8ETZHh7FXeQbyxpDjZYV13SKWV6kJy3ncbq86WYzI9Q=; b=eFpw96ZbjXDuJsMPL1zbb02WbvhCVdZ4wv+/FLDIEJj8fjnf2daUto2k6SiFQ1ZzWbWWuN h6msWZwjdfGALjDb2j0vIBOt0AxOJTQwe1+AUgB1dHeHaIoJx7abCjRDTXeapZOvdhH+pJ Nna7HAEggSawbacvqmcgEm8pXRC+mn8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-VgCgk5PWNmKv1s7PrTgqKA-1; Fri, 18 Sep 2020 11:18:34 -0400 X-MC-Unique: VgCgk5PWNmKv1s7PrTgqKA-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E5ED64098; Fri, 18 Sep 2020 15:18:33 +0000 (UTC) Received: from llong.remote.csb (ovpn-112-232.rdu2.redhat.com [10.10.112.232]) by smtp.corp.redhat.com (Postfix) with ESMTP id 428925C225; Fri, 18 Sep 2020 15:18:32 +0000 (UTC) Subject: Re: [PATCH v2] sched, mm: Optimize current_gfp_context() To: "Xu, Yanfei" Cc: Andrew Morton , Peter Zijlstra , Ingo Molnar , Mathieu Desnoyers , Michel Lespinasse , linux-kernel@vger.kernel.org References: <20200618212936.9776-1-longman@redhat.com> <20200811152921.1d43e34ad7aff928c6c1267f@linux-foundation.org> From: Waiman Long Organization: Red Hat Message-ID: Date: Fri, 18 Sep 2020 11:18:31 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/18/20 2:44 AM, Xu, Yanfei wrote: > Hi Waiman, > > On 8/12/20 6:29 AM, Andrew Morton wrote: >> On Thu, 18 Jun 2020 17:29:36 -0400 Waiman Long >> wrote: >> >>> The current_gfp_context() converts a number of PF_MEMALLOC_* >>> per-process >>> flags into the corresponding GFP_* flags for memory allocation. In >>> that function, current->flags is accessed 3 times. That may lead to >>> duplicated access of the same memory location. >>> > I have a puzzle about this comment, what's the meaning about "That may > lead to duplicated access of the same memory location". After using > variable 'pflags', will it not duplicated access the same memory > location? > Looking forward to your reply :) That condition usually won't happen on a non-debug kernel. However, if certain debugging capability is turned on, access to current will be compiled into a bunch of checks and memory accesses. So if current is used multiple times, the same set of codes will be duplicated the same number of times slowing down the operation and increasing code size. By accessing current once, we avoid this overhead in a debug kernel. Cheers, Longman