Received: by 10.192.165.148 with SMTP id m20csp5370249imm; Wed, 9 May 2018 04:04:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqkK1Y1MBR0WjaPU7CDN9OL4tCFa2XhP1CMWlJkDXBAuCZsqwdA64ppG5d+NJIWnDoRdM5y X-Received: by 10.98.99.4 with SMTP id x4mr33175093pfb.94.1525863843948; Wed, 09 May 2018 04:04:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525863843; cv=none; d=google.com; s=arc-20160816; b=oT6Ne3opbOAE/OFd3YKnuJkh1wrO5+milRQIqRrzuThuVvF735g/Tas41iv2Rx+y0F zvSbdwfVMPADv62S/MfREiB6vXHqfvfWXz7aCKrEA1f6ERZxbZfSuTvORFTdaQUnwMtu teA/maIMLM4dm4Tqz9OWHnz8dibrYd4QAKhtJZ22DuFJ2SophmDPQS+hmrTrzpYwii/k 7ydgEfLLIaNfnL9ZW8C7srp0YpBJO9etpOPdru+rNB60aVqYBvuavmDgjOkbklr4Dmzv tjLgqUjqJ7IPIIufV5OkYYXsdhfBV+d3g5rXsmRCD93xHRhsTzUYNHZiPRQVXG+WO3Ib Lu7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature:arc-authentication-results; bh=1O4J8InYKRzIqQGWCBjHwqs2+1j30Rj8QSZckreWiCw=; b=LEJ85IJQeI4033OvhnyPOEzCHycWKZQK30gJVSjSyCi8EYZC71JpT/9Y7+kZd/CELG 7cmAwtYkyoHBgP+mhVaX7hACY9bwlYXIijuBLwqb4IIGP0xd72FUyTlD5yLBAhx62vPZ WEqChWfvCVs1mIfyfJJEorGh0y7Wz/4iVYMAInFyN3UeWajkRrBs95UpHyiMFLQXJOWq e6OhbRrqiiyMV9Rhz+o/TEcFN+wsLHpZTPghNvtnyWz/krW/CteMSgWtGex9VEvUQEW5 WfdUFgj2gjpmWx59fXzr2F4lzV7JnpbtQL3Ki4KFwyrMaBuUT7T0NM7oQGHn5Hwh5M7P 1nvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=Z3xyJLsJ; dkim=pass header.i=@codeaurora.org header.s=default header.b=POeCGKfk; 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 z73si26971616pfj.197.2018.05.09.04.03.48; Wed, 09 May 2018 04:04:03 -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; dkim=pass header.i=@codeaurora.org header.s=default header.b=Z3xyJLsJ; dkim=pass header.i=@codeaurora.org header.s=default header.b=POeCGKfk; 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 S933919AbeEILDg (ORCPT + 99 others); Wed, 9 May 2018 07:03:36 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:41200 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933685AbeEILDe (ORCPT ); Wed, 9 May 2018 07:03:34 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 4513960FE9; Wed, 9 May 2018 11:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525863814; bh=+1PXQ9g0qF5G3qCnv2axV1PQvCB16OJwuNa5CXfvpN8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=Z3xyJLsJzseo6ovnAdC9b75i3OjZB4G+ShOPqndixpxXVLTiqbDlxoR4SHu760Hzn WB/4x+uo2eMIUpSRtQn5O9sWMltBpm2frBPMZUxKL2C3wMAAr6Eo4OoCqWj+oNsCZa KDsVxKVcSCp5ZTDt0ZXP8JmHGzySIcp3Tlo1TVm4= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,T_DKIM_INVALID autolearn=no autolearn_force=no version=3.4.0 Received: from [10.204.82.17] (blr-c-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.19.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: vinmenon@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1787360C66; Wed, 9 May 2018 11:03:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1525863813; bh=+1PXQ9g0qF5G3qCnv2axV1PQvCB16OJwuNa5CXfvpN8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=POeCGKfkO2ESR5cOQQJVtZmkgkviyY7/jNWKv7K5ZiSGQYRbFcFnGbEGQEj3ibRxc Yta+4ujahviZ+d4UThV34pItc/i1AhdRWG0+cqExN75LlYILh7ZWS41xE+cB/P7r4f evAv04qKnMhSkZwTD6/CkPN5azvI4nuOAdTZKbQE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 1787360C66 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=vinmenon@codeaurora.org Subject: Re: [PATCH 6/7] psi: pressure stall information for CPU, memory, and IO To: Johannes Weiner , linux-kernel@vger.kernel.org, linux-mm@kvack.org, linux-block@vger.kernel.org, cgroups@vger.kernel.org Cc: Ingo Molnar , Peter Zijlstra , Andrew Morton , Tejun Heo , Balbir Singh , Mike Galbraith , Oliver Yang , Shakeel Butt , xxx xxx , Taras Kondratiuk , Daniel Walker , Ruslan Ruslichenko , kernel-team@fb.com References: <20180507210135.1823-1-hannes@cmpxchg.org> <20180507210135.1823-7-hannes@cmpxchg.org> From: Vinayak Menon Message-ID: <87060553-2e09-2e2a-13a2-a91345d6df30@codeaurora.org> Date: Wed, 9 May 2018 16:33:24 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <20180507210135.1823-7-hannes@cmpxchg.org> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/8/2018 2:31 AM, Johannes Weiner wrote: > +static void psi_group_update(struct psi_group *group, int cpu, u64 now, > + unsigned int clear, unsigned int set) > +{ > + enum psi_state state = PSI_NONE; > + struct psi_group_cpu *groupc; > + unsigned int *tasks; > + unsigned int to, bo; > + > + groupc = per_cpu_ptr(group->cpus, cpu); > + tasks = groupc->tasks; > + > + /* Update task counts according to the set/clear bitmasks */ > + for (to = 0; (bo = ffs(clear)); to += bo, clear >>= bo) { > + int idx = to + (bo - 1); > + > + if (tasks[idx] == 0 && !psi_bug) { > + printk_deferred(KERN_ERR "psi: task underflow! cpu=%d idx=%d tasks=[%u %u %u %u]\n", > + cpu, idx, tasks[0], tasks[1], > + tasks[2], tasks[3]); > + psi_bug = 1; > + } > + tasks[idx]--; > + } > + for (to = 0; (bo = ffs(set)); to += bo, set >>= bo) > + tasks[to + (bo - 1)]++; > + > + /* Time in which tasks wait for the CPU */ > + state = PSI_NONE; > + if (tasks[NR_RUNNING] > 1) > + state = PSI_SOME; > + time_state(&groupc->res[PSI_CPU], state, now); > + > + /* Time in which tasks wait for memory */ > + state = PSI_NONE; > + if (tasks[NR_MEMSTALL]) { > + if (!tasks[NR_RUNNING] || > + (cpu_curr(cpu)->flags & PF_MEMSTALL)) > + state = PSI_FULL; > + else > + state = PSI_SOME; > + } > + time_state(&groupc->res[PSI_MEM], state, now); > + > + /* Time in which tasks wait for IO */ > + state = PSI_NONE; > + if (tasks[NR_IOWAIT]) { > + if (!tasks[NR_RUNNING]) > + state = PSI_FULL; > + else > + state = PSI_SOME; > + } > + time_state(&groupc->res[PSI_IO], state, now); > + > + /* Time in which tasks are non-idle, to weigh the CPU in summaries */ > + if (groupc->nonidle) > + groupc->nonidle_time += now - groupc->nonidle_start; > + groupc->nonidle = tasks[NR_RUNNING] || > + tasks[NR_IOWAIT] || tasks[NR_MEMSTALL]; > + if (groupc->nonidle) > + groupc->nonidle_start = now; > + > + /* Kick the stats aggregation worker if it's gone to sleep */ > + if (!delayed_work_pending(&group->clock_work)) This causes a crash when the work is scheduled before system_wq is up. In my case when the first schedule was called from kthreadd. And I had to do this to make it work. if (keventd_up() && !delayed_work_pending(&group->clock_work)) > + schedule_delayed_work(&group->clock_work, MY_LOAD_FREQ); > +} > + > +void psi_task_change(struct task_struct *task, u64 now, int clear, int set) > +{ > + struct cgroup *cgroup, *parent; unused variables Thanks, Vinayak