Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp35889ybt; Tue, 23 Jun 2020 14:37:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh4G+vVj8ur6cAjX9p3TQJ8eS/hIqqFU+3+j3rwVp+IGWspLQC9wHjjKqDt2rHddGGuHxd X-Received: by 2002:a17:906:4a0c:: with SMTP id w12mr763507eju.106.1592948227034; Tue, 23 Jun 2020 14:37:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592948227; cv=none; d=google.com; s=arc-20160816; b=M29xAdE/UU774pUAQnq3/yopFpzMlTv2HUNkY2qddRggj5GQMfOinPSnvEod/lCrSc G/jEBEfzVftY2Uy62hFYzj/Z+c1UZagiAW7biYcD4FTj6glcyxEiERQ4J7eNmr5HVITl dFOxUXY1TrtjIGPxhiPp4skmGzBnAW+h5XnruCu0mv0W7Kx3D83R0zLq4wpmQgf1HaVR SLiC3uGkN8lytQmHz76n5JjkUP5ljZLCpx84Ae+OHP858xcMxgo7BAOQfWUxbM/smDLq ShfZL2hrRYiScxRYDkFTJ0Yvb5ZChKSpgWG+dd8y81JobyNND0MTN8by6ahQymyXOOdv KqLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:from:subject:cc:to:message-id:date; bh=DmOAvaIhCxu1v+848BSUEFEgIlCuhnufWFQD7DGTlSU=; b=wyI7qeQn0uBxzOsFEUMnJ6/vUG3Bo6z5o+DmzlvD1G490vU7/HK2I/B7rLtyv9SU3p g/BR+LlppF4HJOAGMKucUCm9kk83F216w871lnOc3MYCkELn6wUqSoWRI/yv/6K0Nx+2 YTdXQS2xu+Y6dCdvrHd1SfhxpSDIjLXmXE7JicWdRIr7jpMz4Fq+NJLFCf7K0sFRXCYH P20EntWTQIxpQog1ZI0/yHrhkHw+i3I6RrMRvKN/yRjiaVFnIxFbvaGt+WrKC30keW4S sPZGzJ7UbHKOiC6Ycu+zHuIfMXUHAbuu5WpXxjuZTdCbYMc8H46xPNTbQg6iQnPFrQYz kFmQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z1si6571214eju.7.2020.06.23.14.36.42; Tue, 23 Jun 2020 14:37:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389334AbgFWVdS (ORCPT + 99 others); Tue, 23 Jun 2020 17:33:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35236 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391365AbgFWVdO (ORCPT ); Tue, 23 Jun 2020 17:33:14 -0400 Received: from shards.monkeyblade.net (shards.monkeyblade.net [IPv6:2620:137:e000::1:9]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 827C9C061573; Tue, 23 Jun 2020 14:33:14 -0700 (PDT) Received: from localhost (unknown [IPv6:2601:601:9f00:477::3d5]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) (Authenticated sender: davem-davemloft) by shards.monkeyblade.net (Postfix) with ESMTPSA id C76DA129425B6; Tue, 23 Jun 2020 14:33:13 -0700 (PDT) Date: Tue, 23 Jun 2020 14:33:11 -0700 (PDT) Message-Id: <20200623.143311.995885759487352025.davem@davemloft.net> To: likaige@loongson.cn Cc: benve@cisco.com, _govind@gmx.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, lixuefeng@loongson.cn, yangtiezhu@loongson.cn Subject: Re: [PATCH RESEND] net/cisco: Fix a sleep-in-atomic-context bug in enic_init_affinity_hint() From: David Miller In-Reply-To: <1592899989-22049-1-git-send-email-likaige@loongson.cn> References: <1592899989-22049-1-git-send-email-likaige@loongson.cn> X-Mailer: Mew version 6.8 on Emacs 26.3 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Tue, 23 Jun 2020 14:33:14 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kaige Li Date: Tue, 23 Jun 2020 16:13:09 +0800 > The kernel module may sleep with holding a spinlock. > > The function call paths (from bottom to top) are: > > [FUNC] zalloc_cpumask_var(GFP_KERNEL) > drivers/net/ethernet/cisco/enic/enic_main.c, 125: zalloc_cpumask_var in enic_init_affinity_hint > drivers/net/ethernet/cisco/enic/enic_main.c, 1918: enic_init_affinity_hint in enic_open > drivers/net/ethernet/cisco/enic/enic_main.c, 2348: enic_open in enic_reset > drivers/net/ethernet/cisco/enic/enic_main.c, 2341: spin_lock in enic_reset > > To fix this bug, GFP_KERNEL is replaced with GFP_ATOMIC. > > Signed-off-by: Kaige Li Just grepping around for GFP_KERNEL usage in atomic contexts I guess is fine. But you really have to look at the bigger picture. Calling a NIC driver open function from a context holding a spinlock is very much the real problem, so many operations have to sleep and in face that ->ndo_open() method is defined as being allowed to sleep and that's why the core networking never invokes it with spinlocks held.