From patchwork Wed Aug 14 10:41:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Rutland X-Patchwork-Id: 171260 Delivered-To: patch@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp645574ily; Wed, 14 Aug 2019 03:41:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/dcbsdWN1wMC9IXk2beRcrHYTLNrJdfyOQN21Bsllw4XhW4LxEGLiVIAc1NI/iZYcrdNu X-Received: by 2002:a62:e109:: with SMTP id q9mr12401709pfh.71.1565779315060; Wed, 14 Aug 2019 03:41:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565779315; cv=none; d=google.com; s=arc-20160816; b=qlJNPgKOp97zwTG/vwl6CCzI5jxZ+29AU5CRmRNJjtN9lgtYqJ8jA/mKEOkyK+Yyz/ DvLum1Y8BQnhwz+j7dopkdnMbAgbDymAIo3uXTWSpmEwV1hJumUJxSwdsANEyiMTWkf7 S0tlaZYYX+v4vsW/2bova+UEsIyrLWJnT4gpJ+g+ypyYlE8oBEF9LwOWtOGzaVyIRYlE L2A7hMGkc69mLuuRcT5zEe+PWM1Vl5BVH7mSxzoTmKtB372mqhn97y9k+yYumVVJyXq7 nhUXRkQ8cFVq9CGEm+8V1KuVNJOQ5pHs6RMGQrl4FZoE/duU6xlPFl2m3qGcR/F/7UzX /WVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=H5RIRfAWx3VZiYyMFatbho5ZtawrDs1nrodYDvMNz+Y=; b=Hw+o+SB+13JyLsxohvs1DlAL3O6xM1QCNAuB07Sj2L+2a52gV8MxkEEbO+97VUdwHJ q/D2JSqpPYVq74vioWXyBh7lJkMk06hSlJW+Q7mUEGH4cdludxylXdbl3662Sjqezz5Q vyTNuSH5yM2CrHCvruVKTWpkYmLQV0hrPmqowW0DT6E2wfpJ8h2UR25gJkMtXtjZ6ydu NIPmN6maw2d5nwl7KLmkHcrZGERd0KjAttxYZ0Hok2LUsacMzU+eKoV0RtyQEao+bzxO C/jSPp4SzxiDoU/wLqLlPXhijGSCNB/Zcb1Dj2aNea2T0UP6MvrlQiPD5wEBQWEQq8DR TLOQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l6si67659284pgg.489.2019.08.14.03.41.54; Wed, 14 Aug 2019 03:41:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727478AbfHNKlx (ORCPT + 28 others); Wed, 14 Aug 2019 06:41:53 -0400 Received: from foss.arm.com ([217.140.110.172]:51882 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727122AbfHNKlq (ORCPT ); Wed, 14 Aug 2019 06:41:46 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 66B151576; Wed, 14 Aug 2019 03:41:46 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 9024D3F706; Wed, 14 Aug 2019 03:41:44 -0700 (PDT) From: Mark Rutland To: linux-kernel@vger.kernel.org Cc: ak@linux.intel.com, akpm@linux-foundation.org, bigeasy@linutronix.de, bp@suse.de, catalin.marinas@arm.com, davem@davemloft.net, hch@lst.de, kan.liang@intel.com, mark.rutland@arm.com, mingo@kernel.org, peterz@infradead.org, riel@surriel.com, will@kernel.org Subject: [PATCH 3/9] kmemleak: correctly check for kthreads Date: Wed, 14 Aug 2019 11:41:25 +0100 Message-Id: <20190814104131.20190-4-mark.rutland@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20190814104131.20190-1-mark.rutland@arm.com> References: <20190814104131.20190-1-mark.rutland@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In general, a non-NULL current->mm doesn't imply that current is a kthread, as kthreads can install an mm via use_mm(), and so it's preferable to use is_kthread() to determine whether a thread is a kthread. For consistency, let's use is_kthread() here. Signed-off-by: Mark Rutland Cc: Catalin Marinas Cc: Ingo Molnar Cc: Peter Zijlstra --- mm/kmemleak.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.11.0 Acked-by: Catalin Marinas diff --git a/mm/kmemleak.c b/mm/kmemleak.c index 6e9e8cca663e..42ea3c14b577 100644 --- a/mm/kmemleak.c +++ b/mm/kmemleak.c @@ -1290,10 +1290,10 @@ static int scan_should_stop(void) * This function may be called from either process or kthread context, * hence the need to check for both stop conditions. */ - if (current->mm) - return signal_pending(current); - else + if (is_kthread(current)) return kthread_should_stop(); + else + return signal_pending(current); return 0; }