Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp411319pxb; Thu, 17 Feb 2022 06:48:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJx72Y/4ybAbrWyeto+E7LA9g6gKljYWy43n+L8rgmGBPe8Mkh6m6exogrQfQtbz0HVbiQVi X-Received: by 2002:a17:906:fcbb:b0:6cd:f8fa:e356 with SMTP id qw27-20020a170906fcbb00b006cdf8fae356mr2557990ejb.436.1645109332007; Thu, 17 Feb 2022 06:48:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645109332; cv=none; d=google.com; s=arc-20160816; b=RndnbiOArm0exzpDl9RHsQnoJ6uN07sYrJ6ZPe4YwksrXDoVbGmGKIymX240zw2Xwp XTbN2wKbtuSXwJAtFtxA8RBZGGFx8oMS0rli7NcK3NrN10OHdWUC7/f3fxFPwJLZ4xGq aw5G6ZGEr61Oynau6ZfBVzQpS7wq3km/HhW8k8oeCgwiRX4wzdygc8rV92xMZnLW0KqG kTZQrOk7gimWtvP+sI0azhbw6urB6yACSKy2Rnh/UAInS/ektpJeD2n5qXsyNflaJc8c R5Wr64M6vomlwjdbZqyKw4PH/qoqwQU4an7mZWH8PX5VGdCDoTOCRDplkFPUs7JXgcs6 nMQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:organization :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/4eqxzeBPdbxahKma29NjeYOuILVaEAHPDoZJAeZhQc=; b=h5WzWGErNMQ/1Pb2FfXBOezYWG91xVdJVyOwc7UGXfBCI4ts+xPRUTPt1Biq3qQ59+ jrNWruvw4A1c2ZEGXhWgEl0nbFVKl4/+5bPD2zG0LoaAK+j8qKFsWsAmVo6+YzGZat6n kje7RpKOGxdV2d4MBDXj23RJ4biSjWB+UQboGM7z0a+Aqsfha71e3D94qmuB23Q9kEum I2UGQpGotUO4ZteRD82eh3npF8Y1vMcX5xq+f1XTYTkwV6C6Z2X1nK+m3CIGWDSH+vz/ Qp/OaZpSFbQ0Av5KnqO+5f/CH0ldrrMYTJh/JOMHjndwlcm4sG1UbfC0qr7PAZpWoq/X uxRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=iCQnksXy; 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=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id fy22si1504443ejc.726.2022.02.17.06.48.28; Thu, 17 Feb 2022 06:48:51 -0800 (PST) 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=@intel.com header.s=Intel header.b=iCQnksXy; 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=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241712AbiBQOFn (ORCPT + 99 others); Thu, 17 Feb 2022 09:05:43 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:55914 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241582AbiBQOFg (ORCPT ); Thu, 17 Feb 2022 09:05:36 -0500 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9E016145AFD; Thu, 17 Feb 2022 06:05:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1645106712; x=1676642712; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=mmcVCbEg/LT9UwII2j+BYuiQo6K4SH6OPf0Nj6nyyHk=; b=iCQnksXymfbJUZ7jW4zQzHayV0Ygi5d7F0IeHcVmMHFpVzviYs6sK09m tBYMPyV961rvEvXBN+jWIVNg/+42OhufmXGZgDFA9s4mMP0DLeASRECXs fh02kd0E/QeYbbLgOhGuc6ggQdoNhKNBaIRL369z1Jdymlq17c3K2iDTI W3i0ic4b9JI7tagmwNNeGhRn8DyuTInPdTqLZYALJEa93KmC7Id3tZoNH vLayiKooRtWhRsysRWQGiR+OjqmzsObCQhcmTtcrh8Z+Gf61bnI6eJOXY fV707aqhjGPeTFq2vtfKFGv0XSmz2Cneq6F82ZCL9Fuj53NUJ0QdvrvXk w==; X-IronPort-AV: E=McAfee;i="6200,9189,10260"; a="231501882" X-IronPort-AV: E=Sophos;i="5.88,376,1635231600"; d="scan'208";a="231501882" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 06:05:12 -0800 X-IronPort-AV: E=Sophos;i="5.88,376,1635231600"; d="scan'208";a="530241277" Received: from lab-ah.igk.intel.com ([10.91.215.196]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Feb 2022 06:05:09 -0800 From: Andrzej Hajda To: linux-kernel@vger.kernel.org, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, netdev Cc: Andrzej Hajda , Jani Nikula , Daniel Vetter , Lucas De Marchi , Chris Wilson , Eric Dumazet , Dmitry Vyukov , Jakub Kicinski Subject: [PATCH 5/9] lib/ref_tracker: improve allocation flags Date: Thu, 17 Feb 2022 15:04:37 +0100 Message-Id: <20220217140441.1218045-6-andrzej.hajda@intel.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220217140441.1218045-1-andrzej.hajda@intel.com> References: <20220217140441.1218045-1-andrzej.hajda@intel.com> MIME-Version: 1.0 Organization: Intel Technology Poland sp. z o.o. - ul. Slowackiego 173, 80-298 Gdansk - KRS 101882 - NIP 957-07-52-316 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE,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 Library can be called in non-sleeping context, so it should not use __GFP_NOFAIL. Instead it should calmly handle allocation fails, for this __GFP_NOWARN has been added as well. Signed-off-by: Andrzej Hajda --- lib/ref_tracker.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/ref_tracker.c b/lib/ref_tracker.c index 7b00bca300043..c8441ffbb058a 100644 --- a/lib/ref_tracker.c +++ b/lib/ref_tracker.c @@ -59,7 +59,7 @@ __ref_tracker_dir_pr_ostream(struct ref_tracker_dir *dir, if (list_empty(&dir->list)) return; - sbuf = kmalloc(STACK_BUF_SIZE, GFP_NOWAIT); + sbuf = kmalloc(STACK_BUF_SIZE, GFP_NOWAIT | __GFP_NOWARN); list_for_each_entry(tracker, &dir->list, head) ++total; @@ -154,11 +154,11 @@ int ref_tracker_alloc(struct ref_tracker_dir *dir, unsigned long entries[REF_TRACKER_STACK_ENTRIES]; struct ref_tracker *tracker; unsigned int nr_entries; - gfp_t gfp_mask = gfp; + gfp_t gfp_mask; unsigned long flags; - if (gfp & __GFP_DIRECT_RECLAIM) - gfp_mask |= __GFP_NOFAIL; + gfp |= __GFP_NOWARN; + gfp_mask = (gfp & __GFP_DIRECT_RECLAIM) ? (gfp | __GFP_NOFAIL) : gfp; *trackerp = tracker = kzalloc(sizeof(*tracker), gfp_mask); if (unlikely(!tracker)) { pr_err_once("memory allocation failure, unreliable refcount tracker.\n"); @@ -191,7 +191,8 @@ int ref_tracker_free(struct ref_tracker_dir *dir, } nr_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1); nr_entries = filter_irq_stacks(entries, nr_entries); - stack_handle = stack_depot_save(entries, nr_entries, GFP_ATOMIC); + stack_handle = stack_depot_save(entries, nr_entries, + GFP_NOWAIT | __GFP_NOWARN); spin_lock_irqsave(&dir->lock, flags); if (tracker->dead) { -- 2.25.1