Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp826498ybt; Tue, 7 Jul 2020 00:58:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyus8PyPSw8h9AabkdhoIhRdILSmF7+HqFeGhh3ZEQjG1Vq5+hwcVAC5bsakdMczoK4+THj X-Received: by 2002:a17:906:3c42:: with SMTP id i2mr49382978ejg.14.1594108709013; Tue, 07 Jul 2020 00:58:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594108709; cv=none; d=google.com; s=arc-20160816; b=Y7ZpO9Qfj9Y6WLax1Gynn+Mil5RBdGtIqn6XMUF2/UiZrMCrx5wbLwNYYXFbJeScde GXgpH7V9sH1+Pjovv2VPN84aDyc0jZeZr/zL/LYj4TF/bMly93xSO94vhQdZR583SiSs wXk87dyaHVmGM974MoKtVZ8vqjO1ffICOb0XBZctymVa+3iec7mZWrwz+Z+/+xzxOh1G NBKF+1V0kZ4TzoTlHDbIexQb2HFjyMLk3u4VMEbejqLdrNkDr6+q0rqK6v/c51CBQZdl 3njd8a8k66+TQpMbG6J4iBn3xe+WZWfTpJQm5MczaALa+gDLvkDCDN17oEcjkMiHXTwy SV4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:dkim-signature; bh=lWXuOgdJzu7ZoftoY9ZfH+vhGyJSift1pumj8qTxMo8=; b=CYrExTexIKOnOWKshWLCdfqpMaqlaeHWG6N4v1U5fot7yTjXmM/GZnGFTLy0IPp2Q5 8PjQqKYC0kw2cqqueY37LzTHgcHz7ngRE8edBoZ8Lcve9a00Vd5CHuKR+EFdsIobFdbW mX82M4LCpoRQlufzh0b3vggKciCam/YJWn+gAeaAyqaAzn9yQq1eS0RQIYY0m680l3Y7 LXcutkbBOhVn54K/3riYjlzbnSjax1gKYFDNcpL4fEW4xpdZzv6SgfTGPU5nibWtPw32 Zr57xIqIMAPVgM4eTuEYJhtlWCb5NHrDAsMqyV8EsQVjEIZdN5U35nAeWobSA3EUVk9r swFg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=DlxxICUi; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c2si17627137edf.278.2020.07.07.00.58.05; Tue, 07 Jul 2020 00:58:28 -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; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=DlxxICUi; 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; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728121AbgGGHzl (ORCPT + 99 others); Tue, 7 Jul 2020 03:55:41 -0400 Received: from smtp-fw-9102.amazon.com ([207.171.184.29]:52640 "EHLO smtp-fw-9102.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725874AbgGGHzl (ORCPT ); Tue, 7 Jul 2020 03:55:41 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1594108541; x=1625644541; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=lWXuOgdJzu7ZoftoY9ZfH+vhGyJSift1pumj8qTxMo8=; b=DlxxICUiS8asEbruiwPBK4ySfU2laqcE9rrvycGVPEFf98HxFPjTmpB5 rgx8ih22jbHxat3oyj8SCxab7h6/+wbOmKxGgfUQ44nOyH1JYnvRQpL7X MKANeQphNFTH4Z+kysYv9CwjWJX46XTsBeRRJD1Ro/cgkwpdDsQB1mOqr Q=; IronPort-SDR: IRl/32Dz3awjBrVXq3qQicAFvbbUbIPc/2bInKiQD/AYMiP27bWFxDIKfZCO3j/XBdtirzY2mj NwOQWyh5i2Gw== X-IronPort-AV: E=Sophos;i="5.75,323,1589241600"; d="scan'208";a="57882562" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-9102.sea19.amazon.com with ESMTP; 07 Jul 2020 07:55:35 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (Postfix) with ESMTPS id D4EDBA19EB; Tue, 7 Jul 2020 07:55:23 +0000 (UTC) Received: from EX13D31EUA004.ant.amazon.com (10.43.165.161) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 07:55:22 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.34) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 07:55:06 +0000 From: SeongJae Park To: SeongJae Park CC: , SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v17 03/15] mm/damon: Implement region based sampling Date: Tue, 7 Jul 2020 09:54:51 +0200 Message-ID: <20200707075451.24606-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200706115322.29598-4-sjpark@amazon.com> (raw) MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.34] X-ClientProxiedBy: EX13D40UWA003.ant.amazon.com (10.43.160.29) To EX13D31EUA004.ant.amazon.com (10.43.165.161) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 6 Jul 2020 13:53:10 +0200 SeongJae Park wrote: > From: SeongJae Park > > This commit implements DAMON's target address space independent high > level logics for basic access check and region based sampling. This > doesn't work alone, but needs the target address space specific low > level pritimives implementation for the monitoring target address ranges > construction and the access check, though. A reference implementation > of those will be provided by a later commit. Nevertheless, users can > implement and use their own versions for their specific use cases. > [...] > +/** > + * damon_start() - Starts monitoring with given context. > + * @ctx: monitoring context > + * > + * Return: 0 on success, negative error code otherwise. > + */ > +int damon_start(struct damon_ctx *ctx) > +{ > + int err = -EBUSY; > + > + mutex_lock(&ctx->kdamond_lock); > + if (!ctx->kdamond) { > + err = 0; > + ctx->kdamond_stop = false; > + ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond"); Oops, this means 'kdamond_fn' could see the unset '->kdamond'. I will use 'kthread_create()' and 'wake_up_process()' in the next spin. > + if (IS_ERR(ctx->kdamond)) > + err = PTR_ERR(ctx->kdamond); > + } > + mutex_unlock(&ctx->kdamond_lock); > + > + return err; > +} So, the change would be something like below: --- a/mm/damon.c +++ b/mm/damon.c @@ -1464,9 +1464,11 @@ int damon_start(struct damon_ctx *ctx) if (!ctx->kdamond) { err = 0; ctx->kdamond_stop = false; - ctx->kdamond = kthread_run(kdamond_fn, ctx, "kdamond"); + ctx->kdamond = kthread_create(kdamond_fn, ctx, "kdamond"); if (IS_ERR(ctx->kdamond)) err = PTR_ERR(ctx->kdamond); + else + wake_up_process(ctx->kdamond); } mutex_unlock(&ctx->kdamond_lock); Thanks, SeongJae Park