Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp12633576rwd; Fri, 23 Jun 2023 08:35:24 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6QpsWPDbDknt2psmh2vZ6gTfseXjPNMVCvAxWd2z4/lnAr1Fa5INJP/BM3JizeIBjhuJVb X-Received: by 2002:a05:6a20:12d1:b0:10c:6b27:6415 with SMTP id v17-20020a056a2012d100b0010c6b276415mr12247903pzg.8.1687534524138; Fri, 23 Jun 2023 08:35:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687534524; cv=none; d=google.com; s=arc-20160816; b=JhHvcZ0S+mh3nniu5AfagU9xMJM6ApFoHdYwYhy1HpPQDqLO75ZRZ35tx4xwHkhikg Te9NU+K59UmnxuvDPm0/0DFl1D+30OLyyFptaz791XniL0Dn0Wv9IO6S5hAg+9tCmtIX qYez5+PFoHhxfL1NXikEj0anWr98JwpxYVwLU84Dcchka2KyEiYqoek1Qrdxf2iMJCDW jQDbjCvntYNoMTP7zHNp4YvD1QAoVqGgrMQ5pYxWhA8SAk6kL95SEy9inxy/3FED++WW 389uZLRDmPHbeQCWtQ3f6OKgmh6By0tXTVbnkKHKfCwci9yKaqk81RUz+qRWESgAYGyc qZOg== 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=J1o/pL8VifmRkhg9N/fLgEY6Kfl6O6cZ7IhXs/6AQWA=; b=yM+FgAWS8KTw8vuDaflDJOohS1WVuxSCqcRQ8729ivTmZUTnFHP16dual88K3s1wXv IGl1W381ZY5rkzkQf3ulNPwjPNupp35T8BepasjxBvvPuEzCTH69rQH6oYoPhCBugOzQ v4i10Xw4ErcISIoyXXN9RA9NODUB8WJG4O85DBgENHnu5oSKdBXJqtsRZDaGG8oyKH7a zvNAd3Np4K/plGjymTGBSoRC/NYykFDxWQ07MuyCLTUJMXPW1jWV9qbw1c2pXQaJQMzi DmrzZm7RHjYXV0/jJgp6ogMyps88nU1EwWIC8ZYZ63fUmf3KIP0plTpvZHjgUkwZ0IEP zSwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=f3tdIYRj; 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 j64-20020a638b43000000b005533ac674a9si8758882pge.286.2023.06.23.08.35.12; Fri, 23 Jun 2023 08:35:24 -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=f3tdIYRj; 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 S232000AbjFWPR7 (ORCPT + 99 others); Fri, 23 Jun 2023 11:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231949AbjFWPRk (ORCPT ); Fri, 23 Jun 2023 11:17:40 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B21E1E48; Fri, 23 Jun 2023 08:16:58 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-666eba6f3d6so427084b3a.3; Fri, 23 Jun 2023 08:16:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687533415; x=1690125415; h=content-disposition:mime-version:message-id:subject:cc:to:from:date :from:to:cc:subject:date:message-id:reply-to; bh=J1o/pL8VifmRkhg9N/fLgEY6Kfl6O6cZ7IhXs/6AQWA=; b=f3tdIYRj/Qnjj4wTj6d5h1filcc0g7aVJ1duPxCvWWLV6nk3TzSLMBJAcz05+mwBXd EAW9lrn0Z1BQGEYyJnxuhDDhNgwWcEVkQVyjMhoG/NCID9nZGaFO+EiIQqhCwpLWTwIe 676Dmn/Pfg6VVm5mBQfhYuo1qU+G5aK1bDUrQbSJQdVD19Qhaw/akUXlTrKeeaP/EwvY fV5J7jhIRsWF0o3I2U2y2OgGavOTsmLXAmBnuZUd/D1TFfLizibYdTy3q8CLhFk/641S 7heuiRQv+thHKvQyHO1SUFP+1lKJr0Axr7mhatleBGimkng/1jWk1oYTt6GU4OY/hh3p 3noQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687533415; x=1690125415; 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=J1o/pL8VifmRkhg9N/fLgEY6Kfl6O6cZ7IhXs/6AQWA=; b=VgNxWxMz3PF29jZP1FOgW+CxwIdwc8D+TfLHy+xs/9Vn67YwH9D7IuLl5wd7kIdVSv HUimCPev1hyrN26zl5gJYrnYeGCAQkgyFq613VE2GPn8D4jPThFj1WpaVrx1QxsuUF+M MrpYsjn15390XM80ck16kB+hHl4UXW9ELTKWu96cRbmnHB2JrRBK1q3exU8ag2njS+Nq 93AnV2mv7oYG52fQvISjQXo1OwESvnPxV2A4BnEHQzH+lGPLBJhp2jnsrIfq6qGbfYMq fdJz1Gqww/4BWZAQn5qApZmBrLoUQMM40L7m8QsuRmDctVwwkgAHhze+IO5gISXxxJjn Fg1g== X-Gm-Message-State: AC+VfDx3n4t4/HBvi+FJ+Bqt97APNHuNbFOVj3NTwDsuYYOs1Cu2UQsE zWwrhvn9yexjNQiJQLI2toI= X-Received: by 2002:a05:6a21:78a7:b0:10b:e88f:597c with SMTP id bf39-20020a056a2178a700b0010be88f597cmr12054883pzc.44.1687533415380; Fri, 23 Jun 2023 08:16:55 -0700 (PDT) Received: from sumitra.com ([117.199.160.11]) by smtp.gmail.com with ESMTPSA id jc3-20020a17090325c300b001b39ffff838sm7431770plb.25.2023.06.23.08.16.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 08:16:54 -0700 (PDT) Date: Fri, 23 Jun 2023 08:16: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 v4] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag Message-ID: <20230623151644.GA434468@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' and label 'err_free_page'. [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/all/20230613071756.GA359746@sumitra.com/ - Link to v3: https://lore.kernel.org/all/20230622080729.GA426913@sumitra.com/ Changes in v4: Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202306230559.hU5Aonpl-lkp@intel.com/ - Remove unused label 'err_free_page'. 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 | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/lib/test_bpf.c b/lib/test_bpf.c index ade9ac672adb..a5cc5f9fc4e8 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -14381,25 +14381,17 @@ 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); } return skb; -err_free_page: - __free_page(page); err_kfree_skb: kfree_skb(skb); return NULL; -- 2.25.1