Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp2554211ybe; Tue, 3 Sep 2019 14:54:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqgYH0J3MaaTuyLJ0Nx2UxNzdkW6y7cUEhfccPKQ0xigq4JAt4IulH+R3wCtda1Jxpxjrn X-Received: by 2002:a63:7b4d:: with SMTP id k13mr31457613pgn.182.1567547647043; Tue, 03 Sep 2019 14:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567547647; cv=none; d=google.com; s=arc-20160816; b=VCZW91dZPxNluzs3wFIAGc/6UXIBG/wlOPrSdGOvEHO5LVgNwJz1i+fxo6F6dAn988 UKKYnhFX9EiUz0bP7/WS/RRMPRPCeWZWOonV9rR4jklX6+6m1W0/x0gEjTQ9KtPNimno /PqR9+Gp++F+XBcv9M5vbEDc11NVHfn/bqoNkxQ6QcFhQ7Cs8zUQ8TumEM+cremUYpjz 1WaveEXOAJ8FPTKaM3OtpeqUL4jufB4hDdAI2uoeCeaMUv3Jmj32fjLY0NbtbINgtJRE t0vYoF2oflUVXPQ57clzdZjora5/LC87zUsGHasfbM11bNmhdv5bxcD+PNo1zRxhWgAQ MGAQ== 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=8nEs88fIBcfd8Ot9Ays/4FigAzwZ28i8l17+wj87K/Y=; b=RIEq3mDIPPcJFgjY2vSaBqRp6d06IFs5ixAAzia9U2pbxm+Fuf6cBrMndt5cSaUtVw KB8fmqCsutKRCbfA/y/D2C6RBPusX8gUAo0d1DJgC3O0IPa1jQv+tHw6asQTLoq4zuzm zEf53ZlpiT8T6F6JNYndS6EbeRDrOp6G1bOknQiRAnHeaiXcFAXOz1yGoH0OW9fDRCw8 2iwcP1yrxF2y3PTC8lwodkVNhhgCn6sbyfDjQufIqUNAve4zM5n0xpe9UMeTyGVb42t1 HhPGUZNxD9qiOZWTYcYHcQoeCX0JnRGxRFLYplpRT/qasU93lcWcD4dVAs4aRG3fEpWc Cfow== 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 j6si18343037pfh.289.2019.09.03.14.53.51; Tue, 03 Sep 2019 14:54:07 -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 S1726490AbfICVvk (ORCPT + 99 others); Tue, 3 Sep 2019 17:51:40 -0400 Received: from foss.arm.com ([217.140.110.172]:44452 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725882AbfICVvk (ORCPT ); Tue, 3 Sep 2019 17:51:40 -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 6401D337; Tue, 3 Sep 2019 14:51:39 -0700 (PDT) Received: from [10.0.2.15] (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 1A7FE3F718; Tue, 3 Sep 2019 14:51:37 -0700 (PDT) Subject: Re: [PATCH] sched: make struct task_struct::state 32-bit To: Alexey Dobriyan Cc: mingo@redhat.com, peterz@infradead.org, linux-kernel@vger.kernel.org, rcu@vger.kernel.org, linux-block@vger.kernel.org, dm-devel@redhat.com, axboe@kernel.dk, aarcange@redhat.com References: <20190902210558.GA23013@avx2> <20190903181920.GA22358@avx2> From: Valentin Schneider Message-ID: <92ead22e-0580-c720-1a29-7db79d76f7d7@arm.com> Date: Tue, 3 Sep 2019 22:51:30 +0100 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: <20190903181920.GA22358@avx2> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/2019 19:19, Alexey Dobriyan wrote: > On Tue, Sep 03, 2019 at 06:29:06PM +0100, Valentin Schneider wrote: >> On 02/09/2019 22:05, Alexey Dobriyan wrote: >>> 32-bit accesses are shorter than 64-bit accesses on x86_64. >>> Nothing uses 64-bitness of ->state. > >> It looks like you missed a few places. There's a long prev_state in >> sched/core.c::finish_task_switch() for instance. >> >> I suppose that's where coccinelle oughta help but I'm really not fluent >> in that. Is there a way to make it match p.state accesses with p task_struct? >> And if so, can we make it change the type of the variable being read from >> / written to? > > Coccinelle is interesting: basic > > - foo > + bar > > doesn't find "foo" in function arguments. > > I'm scared of coccinelle.> So am I, but I'm even more scared of having no other way of verifying this than doing it "by hand". It's nothing critical here - just some variables that will remain long instead of being int, but I'd like to have some way to verify the change. A coccinelle script would be great, even if it misses some places, I can at least have some trust in it. If I have to verify the whole tree by hand, even with grep/ag, I don't trust I'll do it right. I gave Coccinelle a try, I think I got something for in-function variables: --- @state_var@ struct task_struct *p; identifier prev_state; @@ prev_state = p->state @@ identifier state_var.prev_state; @@ - long prev_state; + int prev_state; --- I tried something for function parameters, which seems to be feasible according to [1], but couldn't get it to work (yet). Here's what I have so far: --- @func_param@ identifier func; identifier p; identifier state; identifier mask; @@ func(struct task_struct *p, const struct cpumask *mask, long state) { ... } @@ identifier func_param.func; identifier func_param.state; expression E1; expression E2; @@ func(E1, - long state, + int state, E2) --- (it should match against kernel/kthread.c::__kthread_bind_mask() but it complains about me not knowing how to write coccinelle patches). With a mix of these we might get somewhere... [1]: http://coccinelle.lip6.fr/docs/main_grammar016.html >> How did you come up with this changeset, did you pickaxe for some regexp? > > No, manually, backtracking up to the call chain. > Maybe I missed a few places. >