Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp10435589rwd; Wed, 21 Jun 2023 23:15:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5GePYerE0vANXglTcHLIZtMYXASGLRocS7iWxRbS9dsDI90p8JHhYOJOUezdR20rStZPrn X-Received: by 2002:a17:90a:52:b0:25b:c53e:4697 with SMTP id 18-20020a17090a005200b0025bc53e4697mr16850873pjb.16.1687414547572; Wed, 21 Jun 2023 23:15:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687414547; cv=none; d=google.com; s=arc-20160816; b=JDazdj3b6ujLALBOHFUhIrrJqQTQEPidlpB9dDtvOQm3vf3jfE8qpcrbPk/xkb2JoB atIlBof3Bew9qazkGaPr3XaAwHM6oZiiVM6zyVlnpdVMO+jX0nE14vB8o8UFDlh8D765 02uW33jlqrOwe/Zjonpvd0tpwXrHT7pu2R9BG64AdS4Hm6paCpR1uwgu91gaINQ79S4u rrK2fH7n5xuzd+WmbQ/O1ocg0Ar0rV/ceyh/wAuZZukDA1CfwvTC4BNZe/rSpf4cMzcu F9VYDGBAhx55NOQqNPdn6i07pa5maadxjBDyVVrm0kOqSnFMAl+vPYpsWx1fLdZM5oA3 RlhA== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=7V9c1bRadtvspE8RX0+kzHasXFfz3GpqArsWjj0tqQ0=; b=QLt4XDSPwG8K5+KP6bKA8CPNfv3KoACGC2pn4yp4NKCbWzru6VR68dTIHo3qe7pbfH kzEqzp/FOcDji8W4haWT0Al6vs02tVVz+as0C2mLf8B7TgJHf5cuh1BZHiWB0qhLp3Gb NPlAAn1M8SGlzXqxtnX/+ADuVavojxHOLSSPuRJPfVLI7KBL0gL3d2DKOVj7W2BZapp4 Kjt7Y9sdcabC3J25H88YpGiG6Nppr8+97Xln4aZA28PoaKszJ9x8RQEULDLoCVIJ7oiB zAFSBMbdzCWEnbcB61dKW98Aoqd2pdR0Kb6ycXY/4QA/kzSdXFcKhfdpCV8pqQJYCwbm 3s/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=kaSh3OC+; 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 e14-20020a17090ab38e00b0025690b76c95si5861896pjr.10.2023.06.21.23.15.35; Wed, 21 Jun 2023 23:15:47 -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=kaSh3OC+; 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 S229784AbjFVFNU (ORCPT + 99 others); Thu, 22 Jun 2023 01:13:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52782 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjFVFNS (ORCPT ); Thu, 22 Jun 2023 01:13:18 -0400 Received: from mail-pg1-x532.google.com (mail-pg1-x532.google.com [IPv6:2607:f8b0:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F101AE9; Wed, 21 Jun 2023 22:13:16 -0700 (PDT) Received: by mail-pg1-x532.google.com with SMTP id 41be03b00d2f7-544c0d768b9so5346903a12.0; Wed, 21 Jun 2023 22:13:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687410796; x=1690002796; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=7V9c1bRadtvspE8RX0+kzHasXFfz3GpqArsWjj0tqQ0=; b=kaSh3OC+Z/AIqk3/6hSw/Glei8j8XdAvZYMFoaTsnLdck8Q/vBT8YWKIga7P3nR+vB FAEaa5Xq+tk5UQgWWm3PkOv1OWqTAymAYryjoyIeFyBn1iXBxATDt2K5ZffMIQOB/jB2 vR5S/P+SCm+lF49Ks/18IMQFJ+fQbTCdBAUVQG3Tvt2drkRWyDmjQ8vPKcnYvh5yEsls eGoZD3t58fD/5eoe9WKd71i1jAq3CWsyFPUWV2+MX2NhqeuJKfWCF47YQuvRXMH03wpL 1/nAmsa/woxa+K7lcC7MlwgtVBsOsb4wv2eqcomqAE13xuWyNgrwgtjzIl3rjgbiojs4 bIjg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687410796; x=1690002796; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7V9c1bRadtvspE8RX0+kzHasXFfz3GpqArsWjj0tqQ0=; b=IxUoH5soXisITsDyVV9SYoKDfa97H5AbIujPH22d6Ek6EVreDXCl3beyZil6JKmpy2 vgSz3+nFa+exua2nhrT+dczKEbjvq4iI8O1fmVP0jUKSja0NckGj0nqoPxrgGi1FB1ot ArBat9bAOIaLLaii3i4DtxhM5HR1oBbXoWrs/zDw3bWsA+OMG5+ND7hCiVBcFEvR119d czNwigwM+0EupSscUsO2OWxuuIosmqkFZvjOHlxDsYP0VFHbyB59cyk18zeKnxhrSzHD rGmSHDamIL7xItDM/9rM4isbhi2s3DkCsrIRtVqLJIPfWqj43i4WwI6Q7kV3KZhF2Y4O VFpA== X-Gm-Message-State: AC+VfDx11/Mp2KPIoxI/O5bv3WfdrsSngShMJBqyzXJejasUVYj8pwse uPL6mG1vAdQwaUOIjMZ5uq0= X-Received: by 2002:a05:6a20:5495:b0:122:5ed2:b521 with SMTP id i21-20020a056a20549500b001225ed2b521mr8864866pzk.59.1687410795736; Wed, 21 Jun 2023 22:13:15 -0700 (PDT) Received: from sumitra.com ([59.89.167.84]) by smtp.gmail.com with ESMTPSA id a7-20020a170902ecc700b001b53be3d942sm4320318plh.232.2023.06.21.22.13.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Jun 2023 22:13:15 -0700 (PDT) Date: Wed, 21 Jun 2023 22:13:06 -0700 From: Sumitra Sharma To: "Fabio M. De Francesco" Cc: 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, Ira Weiny , Deepak R Varma , Sumitra Sharma Subject: Re: [PATCH v2] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag Message-ID: <20230622051306.GA422371@sumitra.com> References: <20230613071756.GA359746@sumitra.com> <3564297.R56niFO833@suse> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <3564297.R56niFO833@suse> 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 On Sun, Jun 18, 2023 at 07:07:00AM +0200, Fabio M. De Francesco wrote: > On marted? 13 giugno 2023 09:17:56 CEST Sumitra Sharma wrote: > > generate_test_data() acquires a page with alloc_page(GFP_KERNEL). Pages > > allocated with GFP_KERNEL cannot come from Highmem. This is why > > there is no need to call kmap() on them. > > > > Therefore, use a plain page_address() on that page. > > > > Suggested-by: Fabio M. De Francesco > > Signed-off-by: Sumitra Sharma > > --- > > > > Changes in v2: > > - Remove the kmap() call and call page_address() instead. > > NIT: Give credit to whom asked you for this removal and explain why the > mapping is not required. > > > - Change the commit subject and message. > > > > lib/test_bpf.c | 3 +-- > > 1 file changed, 1 insertion(+), 2 deletions(-) > > > > diff --git a/lib/test_bpf.c b/lib/test_bpf.c > > index ade9ac672adb..70fcd0bcf14b 100644 > > --- a/lib/test_bpf.c > > +++ b/lib/test_bpf.c > > @@ -14388,11 +14388,10 @@ static void *generate_test_data(struct bpf_test > > *test, int sub) if (!page) > > goto err_kfree_skb; > > > > - ptr = kmap(page); > > + ptr = page_address(page); > > if (!ptr) > > goto err_free_page; > > What is the reason of this test? Could "ptr" ever be NULL? What is the code > checking just few lines above this latter test? > The code is allocating a page using alloc_page() with the GFP_KERNEL flag to obtain a kernel page frame. The checks if (!page) and if (!ptr) are verifying if the page allocation or the mapping operation were successful. If the pages obtained through page_address() are not from the highmem zone, the page_address() function will always return a valid kernel virtual address and will not return NULL. Hence, the check !ptr can be ignored while the !page must remain. I will be working on the v2 patch. I will also add the credits and add new lines to commit message explaining why the mapping is not required. Thank you for the help. Thanks & regards Sumitra > Please, take a deeper look at this function as a whole. > > Fabio > > > memcpy(ptr, test->frag_data, MAX_DATA); > > - kunmap(page); > > skb_add_rx_frag(skb, 0, page, 0, MAX_DATA, MAX_DATA); > > } > > > > -- > > 2.25.1 > > > >