Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp1738667ybn; Thu, 26 Sep 2019 01:13:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwKQdYd/WqwGtjjxRTAEmD1Q1Z6uox6A4cv6DYpUeCPSMDqx2/OreHVAqjZ1nVLQwEhs+ep X-Received: by 2002:a17:906:1d03:: with SMTP id n3mr1929655ejh.287.1569485635258; Thu, 26 Sep 2019 01:13:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569485635; cv=none; d=google.com; s=arc-20160816; b=Uba1PMFjBASzepIGRSPLwILEeN/Pal0e8yyf8JpJ3Pq/QfEgDeaHmqyn2RAmyDW5s6 5Oyb1LN0e1WMBjxDWjUqqxYug8kZCXMEnOwqWyC9XYcEJNsi7Jyv9mbi3teqzPBtay4L Ap/gIBLM77e2ou97S2dXQf7Wnpt0ekCOgyXozugatlGsQlZZxmc+soz7fU8hE5ttvm3O OSMmrldkeRQhB3HQ3SL7lqtQKHVz+/djp2JSXWFWcT36aDY7ruzim48FqPxql7Arqw8l hlszHxjO/YmYyXRdwla2ArFHxu60QtlYYG8G5OwL9/dw6fyOnBtdNmaZPNrznP4Oah2e lcvg== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=O7V3pLLtgavT3Z4bEDyP//43OinwyJwZI9164Pt0xfo=; b=a/fIv/0Gzfa+hzpJMr/cIJRnO/f6M6fyhhq6d6ZQ1gBqc3u04SJmjt1E3gJOHrcJiR DV0bPGtZQNeQqlGzO0JeDwfbTlk5m+aCExWyuQaTxpGEpagbsOw7W37+NHTJEsdef22E UnowA4c3pozqD815j9ysyK6bc8qUnokzLQQm+xmdT5wkhCB0EdaIhvQXS/4KgoHm+RW1 sxyJK/nbdv81uCwr5+Bcaps3TkhOnfqUAd5WWRNiiSXyte+5vDVZUOp8kwd7T0d6Vki9 8L5pY74S1kCssaihN0YzOe5Vl1twrGnbhVwLV6MbZ0My3HrBpa5eMt9NzgsGsCxZ9K+x NWLQ== 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 q10si875709eda.293.2019.09.26.01.13.31; Thu, 26 Sep 2019 01:13: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 S2409580AbfIXOKG (ORCPT + 99 others); Tue, 24 Sep 2019 10:10:06 -0400 Received: from foss.arm.com ([217.140.110.172]:59814 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730778AbfIXOKG (ORCPT ); Tue, 24 Sep 2019 10:10:06 -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 7B747337; Tue, 24 Sep 2019 07:10:05 -0700 (PDT) Received: from [192.168.1.50] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A79B13F59C; Tue, 24 Sep 2019 07:10:01 -0700 (PDT) Subject: Re: [PATCH] sched: fix migration to invalid cpu in __set_cpus_allowed_ptr To: Valentin Schneider , shikemeng , mingo@redhat.com, peterz@infradead.org Cc: linux-kernel@vger.kernel.org References: <979d57f8-802b-57e5-632a-f94ad0f9d6a1@arm.com> <1568535662-14956-1-git-send-email-shikemeng@huawei.com> <5dfd4844-6c36-3b8d-203b-564d7ad7103d@arm.com> <40680310-60b3-589a-d0e8-b4dd723db10a@arm.com> <1d8e6aab-5258-494c-c4cd-1802eda34d59@arm.com> From: Dietmar Eggemann Message-ID: <706581c9-e4ee-967d-b010-4798afd2245e@arm.com> Date: Tue, 24 Sep 2019 16:09:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <1d8e6aab-5258-494c-c4cd-1802eda34d59@arm.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/23/19 6:06 PM, Valentin Schneider wrote: > On 23/09/2019 16:43, Dietmar Eggemann wrote: >> I'm not sure that CONFIG_DEBUG_PER_CPU_MAPS=y will help you here. >> >> __set_cpus_allowed_ptr(...) >> { >> ... >> dest_cpu = cpumask_any_and(...) >> ... >> } >> >> With: >> >> #define cpumask_any_and(mask1, mask2) cpumask_first_and((mask1), (mask2)) >> #define cpumask_first_and(src1p, src2p) cpumask_next_and(-1, (src1p), >> (src2p)) >> >> cpumask_next_and() is called with n = -1 and in this case does not >> invoke cpumask_check(). >> > > It won't warn here because it's still a valid return value, but it should > warn in the cpumask_test_cpu() that follows (in is_cpu_allowed()) because > it would be passed a value >= nr_cpu_ids. So at the very least this config > does catch cpumask_any*() return values being blindly passed to > cpumask_test_cpu(). OK, I see and agree. But IMHO, we still don't call cpumask_test_cpu(dest_cpu, ...), right. What the patch fixes is that it closes the window between two reads of cpu_active_mask in which cpuhp can potentially punch a hole into the cpu_active_mask. If p is not running or queued and it's state is unequal to TASK_WAKING, a 'dest_cpu == nr_cpu_ids' goes unnoticed. Otherwise we see an 'unable to handle kernel paging request' or 'unable to handle page fault for address' bug in migration_cpu_stop() or move_queued_task(). Do I miss something? [...]