From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5802C433B4 for ; Sat, 3 Apr 2021 03:21:57 +0000 (UTC) Received: from shelob.surriel.com (shelob.surriel.com [96.67.55.147]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 33746610D0 for ; Sat, 3 Apr 2021 03:21:57 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 33746610D0 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=vt.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kernelnewbies-bounces@kernelnewbies.org Received: from localhost ([::1] helo=shelob.surriel.com) by shelob.surriel.com with esmtp (Exim 4.94) (envelope-from ) id 1lSWr4-0002eL-4V; Fri, 02 Apr 2021 23:21:46 -0400 Received: from mail-qk1-x733.google.com ([2607:f8b0:4864:20::733]) by shelob.surriel.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94) (envelope-from ) id 1lSWr1-0002eG-LB for kernelnewbies@kernelnewbies.org; Fri, 02 Apr 2021 23:21:43 -0400 Received: by mail-qk1-x733.google.com with SMTP id c4so6853284qkg.3 for ; Fri, 02 Apr 2021 20:21:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vt-edu.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:in-reply-to:references:mime-version :content-transfer-encoding:date:message-id; bh=ZALCtvyfp7KneevcLYvMjOKAEzPO7YIKJ9ibBzYMi0o=; b=Sv8y9RNOLhshztWp2FzqGGjgzG4HZQ9tAYKlMxa2gN9YnN7jAzBb51qc++MlUf5W8G Tl2LM97CZu0492qmcDUlfWbohBMGJOYW9CiPWbspsscFgfYcOMWPSq51h6okhIagIdFz 1h2jBj60+tqT3rLmulbS4yZfwFWH5x/sB1B5YJtM2x6bTrLudKEWyk28Ln9CBx2Y4pEg wsS3BgNdR6+lyXCvgFGzGhFuA2oqRW+0vow7xpS7rc6kwWjHcSGuBDcI/2NV7s+sKRZ8 8+tD1Q27j4ch0G03E63AEXkjtJdeCWF2P2OHPt8Jo1YTuCYehiGOn2m3Rm1g3Z6/Z77K frvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:in-reply-to:references :mime-version:content-transfer-encoding:date:message-id; bh=ZALCtvyfp7KneevcLYvMjOKAEzPO7YIKJ9ibBzYMi0o=; b=KyJC6WeGhQ2ieagz1XnE4vcnLqGQ5YungxYvavwYo6FkS/SEFnBD9Xeut2+IxsyLTR dz+PFqYR4D73fRjO4EHHaxAR8/L2XZHScu6DVceDDzCpgyCpIp5UxLn0kzQoAyJq3zlS ISLbPVymB0ykFQq5Y1j6mr4G5O1bIdjTtWx0TZr+LXJ/EYz3umzyBbs+usTQbWnJAP0c 0jukywu/+QDVkqslYwxFIA83O6QZub4m1v01biuShKcF091FG7DUN1EHul5m+q5Szqb5 DknSw6IPYfGv/m8YR/VZy/4MwS0LaRK7XnEHOrIS0V8Xks4qb51giHzNi29raGi/+MHZ yHvQ== X-Gm-Message-State: AOAM532IpN4M4OGbIEF4Z1Su+aYDnOIVGKFzKqHzFbaGV4nbYVXLxJpP HcSiXmhatuXszlMs2vUrf/8AXg== X-Google-Smtp-Source: ABdhPJxb1yr34o6ewIiG0tHvXofUcV3XWP3VLweDdjCpCRwEBPsqACFfjR0KnMuKg0gJbu0/iTIuTg== X-Received: by 2002:a37:6592:: with SMTP id z140mr16129360qkb.464.1617420101688; Fri, 02 Apr 2021 20:21:41 -0700 (PDT) Received: from turing-police ([2601:5c0:c380:d61::359]) by smtp.gmail.com with ESMTPSA id r8sm8216048qtu.49.2021.04.02.20.21.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Apr 2021 20:21:41 -0700 (PDT) From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Google-Original-From: "Valdis Kl=?utf-8?Q?=c4=93?=tnieks" X-Mailer: exmh version 2.9.0 11/07/2018 with nmh-1.7+dev To: Navin P Subject: Re: pid start time and new display field in proc pid stat [ race in task->start_boottime , start_time] In-Reply-To: References: Mime-Version: 1.0 Date: Fri, 02 Apr 2021 23:21:40 -0400 Message-ID: <105522.1617420100@turing-police> Cc: kernelnewbies X-BeenThere: kernelnewbies@kernelnewbies.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Learn about the Linux kernel List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: multipart/mixed; boundary="===============8619236880207258279==" Errors-To: kernelnewbies-bounces@kernelnewbies.org --===============8619236880207258279== Content-Type: multipart/signed; boundary="==_Exmh_1617420099_94693P"; micalg=pgp-sha1; protocol="application/pgp-signature" Content-Transfer-Encoding: 7bit --==_Exmh_1617420099_94693P Content-Type: text/plain; charset=us-ascii On Thu, 01 Apr 2021 20:20:04 +0530, Navin P said: > After printing the task->start_boottime as 53rd field, i found > multiple process containing same value due to a race. The race exists > for p->start_time as well. Well, yeah. There's no existing reason that the kernel shouldn't be able to spawn processes on two CPUs in parallel (and initialize the start_time field to the same value along the way). There should be as little synchronizing locking as possible, and if you need to do something that requires locking, you should probably piggyback it on top of a code section that already has the appropriate locks in place. > What are the other ways that can be used to fix this problem ? Is there a particular reason why your code *needs* to have different unique values for the start_time and start_boottime fields? If your code needs something unique per-process, the tuple (start_time, PID) *will* be unique system-wide. Or just PID. In other words, what problem are you trying to solve by making the start_time unique? --==_Exmh_1617420099_94693P Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Comment: Exmh version 2.9.0 11/07/2018 iQIVAwUBYGffQwdmEQWDXROgAQLHNg//bmzj9qXeFxJxgGNMGTDFq90h/Y7wnrtJ U5s2k0OPLD3pk1ogYoXKw7yETHOOz45L+R2ZcKjEj2y6Mcb2bC1OI2da/4oGeNBt 8/RrdBo7twi6YTXaG3aIe0WqkIT67SvJFJtmN23SLMrR4qYuI0b1c+Xpe4ZqxIOU TAMigNRgn1qkevtqJSiJB5P/jw9c1XbIWXzHDZcuvKaOGBcwWPkfrP5VNQyOFgrW 6Vl9aK9JPOMWBXHYf984SbPhd0yj1QmWGN129mprYxr7vZ8DiWvMDvnTfT1Q7vj+ sEw6xgLuJLO7Bhm1oz1bRQkWpDwY5DwasEgj5PwH6d2TOnRSisFBvsxEnjvHM/5R quUPzkscuFmjIXAjt+de61myyUMZcNrfyNqIHP7KE3qn+sx3t3vmDH6RSe6Yb+Gr 6Qjek+/woBbE1A47vzgsVSS0rxHfwgO1uFJ6VdZPZNHPC8im0pUbQLL3/7kmbRQ4 3B8aHpHeIuYmLEaQ95Gy6ImfSSeTRIeMzU5OZH0Abs5GxYBI5mo4w+AA86S093/b qiAb9EHGMtbBsP2ldk+zLO8Ik88zm81ZSt6B+OleKyJ/M5jKPWT/JGaZ0lIYz4eB ncs2Gu2Tk1V2JXAw8yOvPe3fLTe/j2CEBxVbwWi4jzFVdpoVlDh3grM64dnSdvVX 012GSTif9UU= =8fRz -----END PGP SIGNATURE----- --==_Exmh_1617420099_94693P-- --===============8619236880207258279== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Kernelnewbies mailing list Kernelnewbies@kernelnewbies.org https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies --===============8619236880207258279==--