Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10537222rwd; Thu, 22 Jun 2023 01:03:03 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6xLTfB6zgNYslQ6DvroFiIfeIt5fXuVnND+uKTRPJLPXS7S7Kzaki+cE8fHHZXsiUR3mIf X-Received: by 2002:a05:6a21:108d:b0:114:f824:67c with SMTP id nl13-20020a056a21108d00b00114f824067cmr13405556pzb.33.1687420983247; Thu, 22 Jun 2023 01:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687420983; cv=none; d=google.com; s=arc-20160816; b=lCAI7992v0Yf4Ft9inJeGAyCCdSHazYOQKMSnylSJAcHgtjTeFOi2nLXTODlMRQx/u vaZQXFdKjMA4nnuJQyOggRVinkXZIgXMJ0ttTPwMt/juWSl31IN2Y+1qeVp52IbweWIP FwekvnNSatrWD14yaHx9YmDl5CFbHN4qHCAVQpCTl8gP0aBupodCRV++ChsFsYrjcyWO 3AsXUuLawEcSOSCQWA3lXuG9fvnwFydXMMc79Br7FeOHAjMpSj9r9+Zcj7+Cy8yBpFyl Qlvf/+bigLmaDmR145T2gqEFS75ytU8bqdjnZWdv14ahf22hNZjQA71uzRePNzPIMDUR jhJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=1zvHJttdtiCO46p+k5M+Fw9sy+2nAJFqu/9noB7Z5VY=; b=zPEPYbRzuL5JhNylwOSkPCr7utuWrpQdUkNMupbz+lRf2lKz3SbFUYAqyZVtwo5i2K T0Rk8+SsfBLrWiBE9N8nYXFuKJwIcA4fkYSI5iKIkk5f1kUfc9LrC3UtzhyLJupsjV2n SN+jm91PR0CqpcZAStGAT4AhRwHNzZzb3+2En/F4KKFEZ1FQS4QVFr5SW+OqZ0z3+ZdM 5htTsytXQgnLE1Lm0YDwGTISJKqDMb/NoBilhOVZnV5o/BId25Fg7N9jKvRKAroKEGDQ hVU9Jd1MAUByMmsov6fXQAHm31OS9svdS0USAKMgGv7SskJ3qJUeGVQ9dDl8s7Ib20pu 9PgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b="A/8+Y5aZ"; 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 p15-20020a170902e74f00b001b54013c021si6396097plf.529.2023.06.22.01.02.51; Thu, 22 Jun 2023 01:03:03 -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=20221208 header.b="A/8+Y5aZ"; 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 S230293AbjFVHxN (ORCPT + 99 others); Thu, 22 Jun 2023 03:53:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230154AbjFVHxK (ORCPT ); Thu, 22 Jun 2023 03:53:10 -0400 Received: from mail-pj1-x1035.google.com (mail-pj1-x1035.google.com [IPv6:2607:f8b0:4864:20::1035]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1163F1FC3; Thu, 22 Jun 2023 00:52:53 -0700 (PDT) Received: by mail-pj1-x1035.google.com with SMTP id 98e67ed59e1d1-25e9e5f9e0cso3901892a91.0; Thu, 22 Jun 2023 00:52:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687420372; x=1690012372; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=1zvHJttdtiCO46p+k5M+Fw9sy+2nAJFqu/9noB7Z5VY=; b=A/8+Y5aZUmT/FJHf7VZQZDImXfjS8v2Xesr4SFZO5W0RMcwQADwQFJpnrfVOTItlI6 Jso3SwSF8TJlzVGc2hTa+T4X3VWy9PrJnyGZTFbEE2kJS6Pk49gQPO0BrUHRlquxOe8x roalo8anv5CtyBrHvDV3dmWi2yLM2w2NZAfE+LeeqvHRJVfdwydCKHM5/rw/Q2RNOr8X EGvkZg16WCU/ISbmAH4PQlIGgSkvR2S9rJvGYN1HcWIoUSt3rGwKwt8CfyptOqwlH8gE +NCwv+E2ZP8AdF6KpfiZDdYvd2FlGmGBBypIMHnhTZuug4U5fB6KrtsqDEBhZWbqrpM8 m51w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687420372; x=1690012372; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1zvHJttdtiCO46p+k5M+Fw9sy+2nAJFqu/9noB7Z5VY=; b=V3C6F0NUkpdCzZyljFV87mb8rJVvmMOnp8/YYtIoceIhNL6z4bFfaL+JmXlbRfCFQx sIKENMqFUeQA+GU24aW4x2Tbqi+6w+4/1sTBBWy4dyPTP7i96BoqsKx7Yo1cwDXyr3ep 1I7SjYTpyRWn07Qe2VAQX/6Ul25m5NSER+EWtnu2nQRncJGlrgkJkkdpq3rK9CoBmiFU 7gmG0pNR8BaAfQSBrNx6wc5YnSpKDzmITUhBRrSpnAPQY92KxOkRha+s2qAUL9VWTUT1 QddtWhd2QyXjIL6x0RtUrTqUn+pkSVKN1NZmUCG7r8cc/eBGTNk/XyvvKgo5/Y+Fj/hQ KJzw== X-Gm-Message-State: AC+VfDx0iAvqs4jW9DU+QExVJzUWN4LiMFttRuJRaImlELlZ5OEPPFEf 2nlo4T1ekoeVLzjNgypC6p0= X-Received: by 2002:a17:90a:c7cd:b0:25b:e081:54e6 with SMTP id gf13-20020a17090ac7cd00b0025be08154e6mr14006745pjb.37.1687420372288; Thu, 22 Jun 2023 00:52:52 -0700 (PDT) Received: from sumitra.com ([59.89.167.84]) by smtp.gmail.com with ESMTPSA id l2-20020a17090b078200b00259b53dccddsm4281769pjz.34.2023.06.22.00.52.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 00:52:51 -0700 (PDT) Date: Thu, 22 Jun 2023 00:52:44 -0700 From: Sumitra Sharma To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , bpf@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ira Weiny , Fabio , Deepak R Varma , Sumitra Sharma Subject: [PATCH v3] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag Message-ID: <20230622075244.GA426694@sumitra.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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,T_SCC_BODY_TEXT_LINE 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 generate_test_data() acquires a page with alloc_page(GFP_KERNEL). The GFP_KERNEL is typical for kernel-internal allocations. The caller requires ZONE_NORMAL or a lower zone for direct access. Therefore the page cannot come from ZONE_HIGHMEM. Thus there's no need to map it with kmap(). Also, the kmap() is being deprecated in favor of kmap_local_page() [1]. Hence, use a plain page_address() directly. Since the page passed to the page_address() is not from the highmem zone, the page_address() function will always return a valid kernel virtual address and will not return NULL. Hence, remove the check 'if (!ptr)'. Remove the unused variable 'ptr'. [1]: https://lore.kernel.org/all/20220813220034.806698-1-ira.weiny @intel.com/ Suggested-by: Fabio M. De Francesco Signed-off-by: Sumitra Sharma --- - Link to v1: https://lore.kernel.org/bpf/20230613073020.GA359792@sumitra.com/T/ - Link to v2: https://lore.kernel.org/lkml/3564297.R56niFO833@suse/T/ Changes in v3: Noted by: Fabio M. De Francesco - Remove the check 'if (!ptr)'. - Remove the unused variable 'ptr'. - Change the commit message. Changes in v2: Noted by: Fabio M. De Francesco - Remove the kmap() call and call page_address() instead. - Change the commit subject and message. lib/test_bpf.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index ade9ac672adb..448bc1b0b8b5 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -14381,18 +14381,12 @@ static void *generate_test_data(struct bpf_test *test, int sub) * single fragment to the skb, filled with * test->frag_data. */ - void *ptr; - page = alloc_page(GFP_KERNEL); if (!page) goto err_kfree_skb; - ptr = kmap(page); - if (!ptr) - goto err_free_page; - memcpy(ptr, test->frag_data, MAX_DATA); - kunmap(page); + memcpy(page_address(page), test->frag_data, MAX_DATA); skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA); } -- 2.25.1