Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp17848168rwd; Tue, 27 Jun 2023 08:16:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6XKSr0SEt9jqO4oN+umoUIePKe4vMIYT3/6FFDGu+NryH8XENEE6u9/Rvs1bbNzWtjy2Db X-Received: by 2002:a05:6a00:2341:b0:680:98c:c58d with SMTP id j1-20020a056a00234100b00680098cc58dmr85497pfj.2.1687878961543; Tue, 27 Jun 2023 08:16:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687878961; cv=none; d=google.com; s=arc-20160816; b=RNhlO1pDxiGm2csmjo8dFciSfevbuuEdGqpADx0zKe1SVtih+e0/0tgfxaS3Z0yj7a jJG3XF/UTWmB0VqxaSW4c877d0T+OOkjJM/l3i8q+7Mza9dCHvHB4EQkPrHutnlg47Ne riAWRSfBM5TCDBjKKwyJiUG9nnaAVq4DwSJu63LgdA5kbdzNdttVEWKCLB3NHodeVtn3 xNIyRKDaQtnhIhHz7ZDVZsvBK+jk+VAzEGNRa6rOIngFXI+Cjk1svOOdb2pND0e5ntsl PTbly1LwwKcOxtO9kY1p5/gS/0PlyJnTGh4hmn9p7NJ6scSidxbdnCcxjNyOiZZ3SWpR b3jQ== 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=QhnmqepLZzo6a37ROg3ReZXKJhIRw52WCvxXCDCV0oM=; fh=14uarQT10el0JM1pcmZL6ponGK+G1F3xdj2uiDjNBjk=; b=uXD8s3U53C0lDdFoZGdX1wRjylr6VvQAhYLBZrYL8eAA2BA4HeTbagmBJOaOwAdMlb Sfh2CRGZ0WlFVTl3smd3vWMODQfN4gT++O9JE4uXI8quUoldBvCtBHI7gBxRcpFBbahB Qa6fZlCb3ZpSc9LyyZj5TnxvzZylULLN/U5P+O6VEZxH6OhrnYXOoD5a3GCBcPerxf2e Dn489TJgRyaxn/sV4GYq3zdIklZAD72tNlNOvRGztx8kzrxTzP5Sb6V0JKHkhuCNtbHY I+MzLnu6QITinP4Wi6fZGUOXaYhHhy8QLwzj90JMiVCngPpEDorBPZ3DwHnIlr9FXZ5s U1Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=H4nVxqcc; 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 q1-20020a056a00150100b00666631f7ed9si7341197pfu.82.2023.06.27.08.15.45; Tue, 27 Jun 2023 08:16:01 -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=H4nVxqcc; 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 S232078AbjF0PBx (ORCPT + 99 others); Tue, 27 Jun 2023 11:01:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231566AbjF0PBv (ORCPT ); Tue, 27 Jun 2023 11:01:51 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52E9C1BE4; Tue, 27 Jun 2023 08:01:50 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-6686a05bc66so2900530b3a.1; Tue, 27 Jun 2023 08:01:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687878110; x=1690470110; 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=QhnmqepLZzo6a37ROg3ReZXKJhIRw52WCvxXCDCV0oM=; b=H4nVxqccKCn4ZL+AGgk0iSwu85tHAREMFJGtTN4faV0WVgoyRViUKcSoCztZy6rmbK 4N71X7Sdwi24PPLMWXm787VRZLcaUOZddlqeNcSTIbTQBD0qYzNdAxwHoY9kb2aRt2PO g0ttVSSMFqwuTKq4m1Wi8ojP/0x6xj4bX+ouwm5FQS6UWkot/6pEPLNjimD4pBMqqi6k 2yY3Ta0HYNkr4avKMz22U8jaQb4OuXYBxAdZUtBsnf0i3+rR0lndyyEKBHKN1nhGUaIp gGdiZI9DQ+82tu+VIKpGnBNm0E6uiWHdIydriekdhyk3g6zNDROBinoytL1ZJ2owwck+ WdBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687878110; x=1690470110; 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=QhnmqepLZzo6a37ROg3ReZXKJhIRw52WCvxXCDCV0oM=; b=D8m/3vnjQsGi0w9bRT7OH7T99N/dovUJq21ArooTbdyIrI8aQxEWNEOWJZd0VPAiXr biOvCVO7plSqZfz7w/Xq4QC3p60UhseUOtueqpIcvnOhhBcdBdKCOPlM1dD/izhPnsZ0 BMCTZXGHGvbnU5hoFaNd46AQvzqGOhx4nrPh0IM0VkI85W4Q+fGb95XUE81eXWdeOnuH Hy07IgajTm+uxzDtzk9G7FC7MUdPugB1zDa4YYeNpxkjcA87+sY+Epi4wnSHuKtrJU5l SGbRIY637LQqi3/14eGlZ+KOlO7SotICoA7siY8QtQckGNSYFWgq3r/M3aB88Ly7hr4H hjEw== X-Gm-Message-State: AC+VfDyvime3rH6NBTppRcO26AY+8ei02M4XWIik5lib738aKFFzzS2U PAh550tmEhw1PKCCEMBYnCI= X-Received: by 2002:a05:6a00:2341:b0:680:98c:c58d with SMTP id j1-20020a056a00234100b00680098cc58dmr26466pfj.2.1687878109504; Tue, 27 Jun 2023 08:01:49 -0700 (PDT) Received: from sumitra.com ([59.95.154.112]) by smtp.gmail.com with ESMTPSA id 204-20020a6300d5000000b0053051d50a48sm5832558pga.79.2023.06.27.08.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Jun 2023 08:01:49 -0700 (PDT) Date: Tue, 27 Jun 2023 08:01:38 -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 v4] lib/test_bpf: Call page_address() on page acquired with GFP_KERNEL flag Message-ID: <20230627150138.GB452923@sumitra.com> References: <20230623151644.GA434468@sumitra.com> <5846758.MhkbZ0Pkbq@suse> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <5846758.MhkbZ0Pkbq@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 Mon, Jun 26, 2023 at 03:07:22PM +0200, Fabio M. De Francesco wrote: > On venerd? 23 giugno 2023 17:16:44 CEST Sumitra Sharma wrote: > > 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 > > I can't see no more things that prevent my tag, then it is... > > Reviewed-by: Fabio M. De Francesco > > Thanks for working on it for all the time it took to get to v4 and for > listening to what you've been suggested to change. > > Well done :-) Thank you, Fabio and Ira, for your tags and kind words :) Thanks & regards Sumitra > > Fabio > > > 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 > > > >