Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1219119pxa; Thu, 13 Aug 2020 03:48:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpoSf7Mvv4tCUbabJLCEdR2E+1ZGeqT4drZVfuUi8MeTN3QK2GyRKmlBo67NBKOf75mIQI X-Received: by 2002:aa7:d285:: with SMTP id w5mr4177788edq.125.1597315685850; Thu, 13 Aug 2020 03:48:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597315685; cv=none; d=google.com; s=arc-20160816; b=RWiKr19EhlJwSUviutIsKIj00Ryn3uYSrPobzgboR5y6F6mM81ndwBb76fs3R6Uuag bRGemJkqhHvySRcP7r6RlGsAm85ryVh9Mqh0BHK0FAGnzRDZgTLDLw6bp5PyEsZ3RmiP Map6EXQMe7MthSTYpnE9/qKBdF1tPEw5y5ZxT9KXckTTBCYP3uYbojM/xi5ytBj8vsDu dVvlxkHnKSDMVtC99bNYODsQ0aSR9rtOj9+zqp7Qg2iLqD9vGUI6GIbYtRzXw8DJvlpc qjwheWN1r41ULlmnfPcstua5OPE2Nzgj/Xa9XOn/v64nXTmoFAOgbno+GmjcjTOADBSC 7fiA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:dkim-signature:dkim-signature:from; bh=HCg1ZdtTl1KhAjawebiFvNnjllljAIdwgNvbFA5RkDM=; b=UYowoEY2F+JprOGS9kkvXGGEYkCK1xgVTqPKo/xemwfL3ZpP17XVOk/7wXVSF+k00Q 38ChdjvMMSQaOxyJVPPsYhA5zScIpA/nkY27OKaH96OY9Q8gcnZrnQnrFSpe9T4bQ1n5 eeHgSkV+yAmG1MC8H4+ShlgRXtfzyYx9is1PW2Pgddb/LmrPRXz0T+kFYUNzpAVm31dp 300cgjgiVqnugeZ60MkiUFxJR505CCCH8PJ0TxztGRsEE09IRqi+ELYjgJ9KH72eJfYF ygcHSoZspUggg2S5ASsKa12JHlA2BYkZ9oT4JaMRYxACdl0ynZZrQv9FJRLQPvktZAZq N3lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bEywIbIK; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XEDJQTTr; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e5si3031554ejc.182.2020.08.13.03.47.42; Thu, 13 Aug 2020 03:48:05 -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=@linutronix.de header.s=2020 header.b=bEywIbIK; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=XEDJQTTr; 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=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726531AbgHMKqK (ORCPT + 99 others); Thu, 13 Aug 2020 06:46:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36056 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726621AbgHMKqH (ORCPT ); Thu, 13 Aug 2020 06:46:07 -0400 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06AACC061757 for ; Thu, 13 Aug 2020 03:46:07 -0700 (PDT) From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1597315565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HCg1ZdtTl1KhAjawebiFvNnjllljAIdwgNvbFA5RkDM=; b=bEywIbIK22XdO0ai4D1Bx5DPlNeBk5voSqr1vXsP7AVobytK6wgdxdlRVmMkzuluT+WZVx MDloLbbbkcCw5CYBGSqNJnqOP8wLSBb/i1z9Pu72J2vywDadD+M24YBHPspCFrFRlvPekG ht4wyZ3kWRvi0+eoeLZPIX9yFEn9oNmFg9L3tgIkYe3TwlyIkQYXx7vohIewPzrZjxYvMK 1RtPof3s4s5hVkx1bniz52OVM69jGptBpmwKGm0OwFJfTd8dfefh2BJbR9fZlgOsbGbDZw tajT9V9wYYJLv6pX3PxRuB1fBjHLbFL268WOHVjZ5sHYR7LW6WcoSseCUxgGTw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1597315565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=HCg1ZdtTl1KhAjawebiFvNnjllljAIdwgNvbFA5RkDM=; b=XEDJQTTrOA+Ajl0PYX6L2bHeRYagwpHbpMD6GjEmX5RnhID6Q16IBfPaZLonVzbv8Bm8QM 1oIdgPsL0mAp4JDA== To: Qianli Zhao , john.stultz@linaro.org, sboyd@kernel.org Cc: linux-kernel@vger.kernel.org, zhaoqianli@xiaomi.com Subject: Re: [PATCH] timer: mask unnecessary set of flags in do_init_timer In-Reply-To: <1596767378-27241-1-git-send-email-zhaoqianligood@gmail.com> References: <1596767378-27241-1-git-send-email-zhaoqianligood@gmail.com> Date: Thu, 13 Aug 2020 12:46:05 +0200 Message-ID: <87h7t6lt76.fsf@nanos.tec.linutronix.de> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Qianli Zhao writes: Please start the first word after the colon with an upper case letter. > do_init_timer can specify flags of timer_list, Please write do_init_timer() so it's entirely clear that this is about a function. > but this function does not expect to specify the CPU or idx. or idx does not mean anything unless someone looks at the code. Changelogs want to explain things so they can be understood without staring at the code. > If user invoking do_init_timer and specify CPU, > The result may not what we expected. Right. And which caller exactly hands in crappy flags? > E.g: > do_init_timer invoked in core2,and specify flags 0x1 > final result flags is 0x3.If the specified CPU number > exceeds the actual number,more serious problems will happen More serious problems is not a really helpful technical explanation and 0x3 does not make sense for a changelog reader either because it again requires to look up the code. > timer->entry.pprev = NULL; > timer->function = func; > - timer->flags = flags | raw_smp_processor_id(); > + timer->flags = (flags & ~TIMER_BASEMASK & ~TIMER_ARRAYMASK) | > raw_smp_processor_id(); If the caller hands in invalid flags then silently fixing them up is fundamentally wrong. So this wants to be: if (WARN_ON(flags & ~TIMER_INIT_FLAGS)) flags &= TIMER_INIT_FLAGS; and TIMER_INIT_FLAGS wants to be exactly the set of flags which are valid for being handed in by a caller, i.e.: TIMER_DEFFERABLE, TIMER_PINNED, TIMER_IRQSAFE Guess what happens when the caller hands in TIMER_MIGRATING? If we do sanity checking then we do it correct and not just silently papering over the particular problem which you ran into. Thanks, tglx