Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp449274pxb; Mon, 25 Apr 2022 13:33:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzcS97BXj8FcpkpDOpLEC59GVixlAxjBdxrBojVRIwFc0h23mep9GJctlfn0v48R7+67uvU X-Received: by 2002:a63:80c6:0:b0:3ab:15d5:ed21 with SMTP id j189-20020a6380c6000000b003ab15d5ed21mr8893450pgd.203.1650918824593; Mon, 25 Apr 2022 13:33:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650918824; cv=none; d=google.com; s=arc-20160816; b=vSCL3hScFBib3q4rt+/ewyGtg/fAdnV0iWpmejsPKzIdt7xhRiVfIRt9ZF9YNpPwJL CbQ9VRlvh2WrQPyAF5/su8Cr9Mp3CwCrgET8rAMYY1TID1c0xa71ZEkOSFYwfwxDHtKY F8oxsZ9Fji3BTPmYMzdvPBkk4NhjXKGCF2xwX4lFfNUSQEQ2Hc0gK3DmR8I7G1IL2k5V tOQHPMhpzuTu3fJ0SPZ4OB6bQO20KCvaM0vr2WwqOwar4lcTT5LcBNDH78z1liWGzABL Y0CNCcgj5NW6vKAu9hlQHQvSStP/7Gbt/ivYEjUdnzVihv1ac4xM4K6uOErC3dHJvhy7 mr0A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4HJrozkvVkscS0zdSWk9LaftjL2z1E2cnMkC2nHI7pY=; b=G6ZManY9byUOwbamV+EHb/dbbclXRFHulJlYlR9f2jpWRPcmyZARRW8C3eMAlFRxe/ tTMcD45BgcQwAbs5r1v9WlGMY+yQUXEZ1rYfAGExihDqRXNI64zfEG/r9PQqhNQ+yKxn zHcj0Ga/SdGE5FT4nZ+AQ9FW2uDV41f4WsrRv+1ZOS1EhVQtIUIekawsj0kj5X6fjZmR VJa5WEgtBUTeOmjJlc9F4FC3RSu+AQRqUN6HRhWPgRu9VDS93n89uCpkAIipZt9xoB58 0bXM+lkLSGuyDZg6McqHRI4bmK0hvtyuitdWySq0uXk555MlEA6thLuMFjQX/DuhXySJ ykeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gitlin4e; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o11-20020a17090ac70b00b001cac9a13c76si253103pjt.108.2022.04.25.13.33.25; Mon, 25 Apr 2022 13:33:44 -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; dkim=pass header.i=@gmail.com header.s=20210112 header.b=gitlin4e; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244144AbiDYSBL (ORCPT + 99 others); Mon, 25 Apr 2022 14:01:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244143AbiDYSBG (ORCPT ); Mon, 25 Apr 2022 14:01:06 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5196433A0E for ; Mon, 25 Apr 2022 10:58:02 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id a1so13741692edt.3 for ; Mon, 25 Apr 2022 10:58:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4HJrozkvVkscS0zdSWk9LaftjL2z1E2cnMkC2nHI7pY=; b=gitlin4eSQ5kEyFnKB9CpAO9Q3nsVpEq4IfwfoQ63ph3VaYJTDat6BhbWTkBxi9kx3 YeGbtuODl9+entPhkyr5TpazRNM8RHiJ8lQTcE+nXzQPQQtBsDUBwfhHsLKUB7w/2bgn qBLInehp/cdVF+tHJHIF7cDP2yRYa0Uin/xEa4B/t2m4A9nQc1wxL0Y3HOF4Ett8gEb+ bi4Q//JL9HzsdKkOox1lyIF/7yFf/lqUol+hUpGX/J+6Ho31bniPadBz5CvqHAHh0yqB 7DLYuzquCDpmjp2A5akX0rKMbBYz1qnsOY7m3F/eVYgusgq3q0IrNkdCT6CFcqlIBYRp iLAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4HJrozkvVkscS0zdSWk9LaftjL2z1E2cnMkC2nHI7pY=; b=goUTzfCk/DVZJLJ6Ms4pczZ/1Uqxv9/Y9Y7WlnmeouX8bTUqrJpCmQvguSueU3DGWV QKsNN7jRykZuGOUVy54eTZaa8aQKSU4A2hA0h6ZjqQRefQAQs+y4g9IGxs0v1P6tGWxL DI8tBDelsunZiWq4EqEjYxmg0JVmfLuVNqBUJIjvscM4vPIiV669PxSMu196TIMgdsGM 1l6kt/rL7GkUmPJxBS3Hbz7gnBHpqBVCRYjoTmVPS6ny9NzXVzUCOKBtN12TkrmlOd4c 9OqokvwzZzzXDxT1sXFYv+Bpq94xCW7Yk8BYfL9r9LS/CPnZ476QN1QMyaaToQXGlpSG zbEg== X-Gm-Message-State: AOAM5337VK00WI7LqB2ate1uwA23NiE5znc/Mrb4Isui8RJUW2rxwxSp 3nDE+jMfrw5hXumhpX9mIyg= X-Received: by 2002:aa7:d9d6:0:b0:425:dafc:2fc6 with SMTP id v22-20020aa7d9d6000000b00425dafc2fc6mr8299494eds.340.1650909480802; Mon, 25 Apr 2022 10:58:00 -0700 (PDT) Received: from localhost.localdomain (host-79-50-86-254.retail.telecomitalia.it. [79.50.86.254]) by smtp.gmail.com with ESMTPSA id ia5-20020a170907a06500b006f392df973bsm1497207ejc.107.2022.04.25.10.57.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Apr 2022 10:57:59 -0700 (PDT) From: "Fabio M. De Francesco" To: Greg Kroah-Hartman , =?UTF-8?q?Arve=20Hj=C3=B8nnev=C3=A5g?= , Todd Kjos , Martijn Coenen , Joel Fernandes , Christian Brauner , Hridya Valsaraju , Suren Baghdasaryan , Ira Weiny , linux-kernel@vger.kernel.org, Christophe JAILLET Cc: "Fabio M. De Francesco" , Todd Kjos Subject: [PATCH v2 1/3] binder: Use memset_page() in binder_alloc_clear_buf() Date: Mon, 25 Apr 2022 19:57:52 +0200 Message-Id: <20220425175754.8180-2-fmdefrancesco@gmail.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220425175754.8180-1-fmdefrancesco@gmail.com> References: <20220425175754.8180-1-fmdefrancesco@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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 The use of kmap() is being deprecated in favor of kmap_local_page() where it is feasible. With kmap_local_page(), the mapping is per thread, CPU local and not globally visible. binder_alloc_clear_buf() is a function where the use of kmap_local_page() in place of kmap() is correctly suited because the mapping is local to the thread. Therefore, use kmap_local_page() / kunmap_local() but, instead of open coding these two functions and adding a memset() of the virtual address of the mapping, prefer memset_page(). Cc: Christophe JAILLET Acked-by: Todd Kjos Signed-off-by: Fabio M. De Francesco --- v1->v2: Add Todd Kjos's tag in the commit message (thanks!) drivers/android/binder_alloc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 2ac1008a5f39..0b3f2f569053 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -1175,14 +1175,11 @@ static void binder_alloc_clear_buf(struct binder_alloc *alloc, unsigned long size; struct page *page; pgoff_t pgoff; - void *kptr; page = binder_alloc_get_page(alloc, buffer, buffer_offset, &pgoff); size = min_t(size_t, bytes, PAGE_SIZE - pgoff); - kptr = kmap(page) + pgoff; - memset(kptr, 0, size); - kunmap(page); + memset_page(page, pgoff, 0, size); bytes -= size; buffer_offset += size; } -- 2.34.1