Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp1602623pxb; Sat, 23 Apr 2022 11:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4LagORoFENzfEJvA5+Xtld2hiT2OsvZG0TPaVlv5xSrDHmWA+k/w4XxRF51hOiu29fkaD X-Received: by 2002:a05:6402:4499:b0:41d:7e83:8565 with SMTP id er25-20020a056402449900b0041d7e838565mr11129840edb.332.1650737649515; Sat, 23 Apr 2022 11:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650737649; cv=none; d=google.com; s=arc-20160816; b=bMznLf8sSzgbgfekFcoy0kXEjC5fhUN0AWDnzqFPgOJ2VwwDPlPjBSB2KlMyt4Y2iw z9kKqpnN7NU1jL4ZPDDbxIlpCCcq0ECFHZC2qvzyZOgMfLEKgXn/ssIi3DRV1mNLSvBG V7zBBm6+iXFdwKlxvO+AbfeoqDJ2fvVJaiZsN8maoopBtCCCAM+t5llf7gVFv8Cnd1jW PQVSgkQQEHP8eKKmn42qNTCZcdxULzJbB3tH6ru5eEHZnBsTjCEMGpaaKbqIDPJZ1J5X 4zbUPhsMsUU/WwO0TETKLHh899YguEabdT3cLVToCFf/vgDkCIUuF1CFd6YQluEODiDS lViw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-language:user-agent :content-transfer-encoding:mime-version:references:message-id:date :subject:from:to; bh=IvaRDROHJHdMIPMJi7CMq5vACfCEu5TG1YCBsOrVEqk=; b=ADPNqb6gmcO6bJoRhiHYP9H1cvAMCaakVLGBEurENGXX4B4JkYykRbpCnRP8bM/l8S xkl/j8F0G6ys+0B9GusH1zeo4iTDJ6u4X/LJfo/aykkcHblXmOLhpGfMgQmiBXB3p3E9 DiVR/8emKBmxKwnJnDa/+v/n20lwcire7HtlnY2dQcscfih5Waz3SXihB8Gv1hDtySlp zBxwMMgdx8obc1enLmEY65U3xRFG3HTwd5R+7snMm36Nva7OhIovSJbk5KOy0TrCqxGi VGdX1j+m8Bs7OGTrxps/3E6n/lNdiuc+1TciAAAF140EI8Yd6sgzwl6G67+fYTcCYG88 pvyw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m10-20020a17090672ca00b006e893c54e01si8830375ejl.533.2022.04.23.11.13.07; Sat, 23 Apr 2022 11:14:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236277AbiDWQF5 (ORCPT + 99 others); Sat, 23 Apr 2022 12:05:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33360 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236251AbiDWQFx (ORCPT ); Sat, 23 Apr 2022 12:05:53 -0400 Received: from ciao.gmane.io (ciao.gmane.io [116.202.254.214]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 884F22496E for ; Sat, 23 Apr 2022 09:02:56 -0700 (PDT) Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1niIDl-0004Qj-VQ for linux-kernel@vger.kernel.org; Sat, 23 Apr 2022 18:02:53 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: linux-kernel@vger.kernel.org From: Christophe JAILLET Subject: Re: [PATCH 3/3] binder: Use kmap_local_page() in binder_alloc_get_page() Date: Sat, 23 Apr 2022 18:02:48 +0200 Message-ID: References: <20220423102421.16869-1-fmdefrancesco@gmail.com> <20220423102421.16869-4-fmdefrancesco@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.7.0 Content-Language: fr In-Reply-To: <20220423102421.16869-4-fmdefrancesco@gmail.com> X-Spam-Status: No, score=-3.5 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Le 23/04/2022 à 12:24, Fabio M. De Francesco a écrit : > The use of kmap_atomic() is being deprecated in favor of kmap_local_page() > where it is feasible. Each call of kmap_atomic() in the kernel creates > a non-preemptible section and disable pagefaults. This could be a source > of unwanted latency, so it should be only used if it is absolutely > required, otherwise kmap_local_page() should be preferred. > > With kmap_local_page(), the mapping is per thread, CPU local and not > globally visible. Furthermore, the mapping can be acquired from any context > (including interrupts). > > Therefore, use kmap_local_page() / kunmap_local() in place of > kmap_atomic() / kunmap_atomic(). > > Signed-off-by: Fabio M. De Francesco > --- > drivers/android/binder_alloc.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c > index 0875c463c002..058595cc7ff0 100644 > --- a/drivers/android/binder_alloc.c > +++ b/drivers/android/binder_alloc.c > @@ -1250,17 +1250,17 @@ static int binder_alloc_do_buffer_copy(struct binder_alloc *alloc, > page = binder_alloc_get_page(alloc, buffer, > buffer_offset, &pgoff); > size = min_t(size_t, bytes, PAGE_SIZE - pgoff); > - base_ptr = kmap_atomic(page); > + base_ptr = kmap_local_page(page); > tmpptr = base_ptr + pgoff; > if (to_buffer) > memcpy(tmpptr, ptr, size); > else > memcpy(ptr, tmpptr, size); in the same spirit as patch 1/3, memcpy_to_page() and memcpy_from_page() looks good candidate to avoid code duplication. Not checked in details, but looks mostly the same. Just my 2c. CJ > /* > - * kunmap_atomic() takes care of flushing the cache > + * kunmap_local() takes care of flushing the cache > * if this device has VIVT cache arch > */ > - kunmap_atomic(base_ptr); > + kunmap_local(base_ptr); > bytes -= size; > pgoff = 0; > ptr = ptr + size;