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=-8.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 6AB8EC43332 for ; Fri, 20 Mar 2020 10:00:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3923B20754 for ; Fri, 20 Mar 2020 10:00:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ArtPZJsu" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbgCTKAN (ORCPT ); Fri, 20 Mar 2020 06:00:13 -0400 Received: from us-smtp-delivery-74.mimecast.com ([63.128.21.74]:26525 "EHLO us-smtp-delivery-74.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727163AbgCTKAM (ORCPT ); Fri, 20 Mar 2020 06:00:12 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584698411; 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=wav6xNqI9ihDDoXx/GoMx+TsMvEpi21uQTIJBLfXuG4=; b=ArtPZJsuV5zjr8g5tZpggswtPafK/aolowqcIzdh/Los1y5qeMzT1xOqlfgcS+XRxy/Vlb bN0i+mXLLlJk0HzlSXH9VFNcIirVXsLxuXDvNlyRIA7iRQiDYaoHYPQFIFw9ossX/l3ECl GshujYM9CekJazDvSqI4FvBRxAeDd94= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-1Zz8HvToOJmcmiDI4OJmtA-1; Fri, 20 Mar 2020 06:00:07 -0400 X-MC-Unique: 1Zz8HvToOJmcmiDI4OJmtA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 960B418CA245; Fri, 20 Mar 2020 10:00:05 +0000 (UTC) Received: from localhost (ovpn-13-97.pek2.redhat.com [10.72.13.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 315A37389C; Fri, 20 Mar 2020 10:00:00 +0000 (UTC) Date: Fri, 20 Mar 2020 17:59:58 +0800 From: Baoquan He To: David Hildenbrand Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, linuxppc-dev@lists.ozlabs.org, linux-hyperv@vger.kernel.org, Wei Yang , Michal Hocko , Greg Kroah-Hartman , Andrew Morton , Michal Hocko , Oscar Salvador , "Rafael J. Wysocki" Subject: Re: [PATCH v3 3/8] drivers/base/memory: store mapping between MMOP_* and string in an array Message-ID: <20200320095958.GF2987@MiWiFi-R3L-srv> References: <20200319131221.14044-1-david@redhat.com> <20200319131221.14044-4-david@redhat.com> <20200320073653.GE2987@MiWiFi-R3L-srv> <166f7f03-eda9-00a8-bd18-128898526313@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <166f7f03-eda9-00a8-bd18-128898526313@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/20/20 at 10:50am, David Hildenbrand wrote: > On 20.03.20 08:36, Baoquan He wrote: > > On 03/19/20 at 02:12pm, David Hildenbrand wrote: > >> Let's use a simple array which we can reuse soon. While at it, move the > >> string->mmop conversion out of the device hotplug lock. > >> > >> Reviewed-by: Wei Yang > >> Acked-by: Michal Hocko > >> Cc: Greg Kroah-Hartman > >> Cc: Andrew Morton > >> Cc: Michal Hocko > >> Cc: Oscar Salvador > >> Cc: "Rafael J. Wysocki" > >> Cc: Baoquan He > >> Cc: Wei Yang > >> Signed-off-by: David Hildenbrand > >> --- > >> drivers/base/memory.c | 38 +++++++++++++++++++++++--------------- > >> 1 file changed, 23 insertions(+), 15 deletions(-) > >> > >> diff --git a/drivers/base/memory.c b/drivers/base/memory.c > >> index e7e77cafef80..8a7f29c0bf97 100644 > >> --- a/drivers/base/memory.c > >> +++ b/drivers/base/memory.c > >> @@ -28,6 +28,24 @@ > >> > >> #define MEMORY_CLASS_NAME "memory" > >> > >> +static const char *const online_type_to_str[] = { > >> + [MMOP_OFFLINE] = "offline", > >> + [MMOP_ONLINE] = "online", > >> + [MMOP_ONLINE_KERNEL] = "online_kernel", > >> + [MMOP_ONLINE_MOVABLE] = "online_movable", > >> +}; > >> + > >> +static int memhp_online_type_from_str(const char *str) > >> +{ > >> + int i; > > > > I would change it as: > > > > for (int i = 0; i < ARRAY_SIZE(online_type_to_str); i++) { > > > > That's not allowed by the C90 standard (and -std=gnu89). > > $ gcc main.c -std=gnu89 > main.c: In function 'main': > main.c:3:2: error: 'for' loop initial declarations are only allowed in > C99 or C11 mode > 3 | for (int i = 0; i < 8; i++) { > | ^~~ Good to know, thanks. > > One of the reasons why > git grep "for (int " > > will result in very little hits (IOW, only 5 in driver code only). > > -- > Thanks, > > David / dhildenb 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=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 6B9C5C4332B for ; Fri, 20 Mar 2020 10:07:17 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (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 B6C9320739 for ; Fri, 20 Mar 2020 10:07:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="ArtPZJsu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B6C9320739 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 48kKFZ6FHLzDrM8 for ; Fri, 20 Mar 2020 21:07:14 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=redhat.com (client-ip=63.128.21.74; helo=us-smtp-delivery-74.mimecast.com; envelope-from=bhe@redhat.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=ArtPZJsu; dkim-atps=neutral Received: from us-smtp-delivery-74.mimecast.com (us-smtp-delivery-74.mimecast.com [63.128.21.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 48kK5V4fQfzDrhl for ; Fri, 20 Mar 2020 21:00:14 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1584698411; 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=wav6xNqI9ihDDoXx/GoMx+TsMvEpi21uQTIJBLfXuG4=; b=ArtPZJsuV5zjr8g5tZpggswtPafK/aolowqcIzdh/Los1y5qeMzT1xOqlfgcS+XRxy/Vlb bN0i+mXLLlJk0HzlSXH9VFNcIirVXsLxuXDvNlyRIA7iRQiDYaoHYPQFIFw9ossX/l3ECl GshujYM9CekJazDvSqI4FvBRxAeDd94= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-256-1Zz8HvToOJmcmiDI4OJmtA-1; Fri, 20 Mar 2020 06:00:07 -0400 X-MC-Unique: 1Zz8HvToOJmcmiDI4OJmtA-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 960B418CA245; Fri, 20 Mar 2020 10:00:05 +0000 (UTC) Received: from localhost (ovpn-13-97.pek2.redhat.com [10.72.13.97]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 315A37389C; Fri, 20 Mar 2020 10:00:00 +0000 (UTC) Date: Fri, 20 Mar 2020 17:59:58 +0800 From: Baoquan He To: David Hildenbrand Subject: Re: [PATCH v3 3/8] drivers/base/memory: store mapping between MMOP_* and string in an array Message-ID: <20200320095958.GF2987@MiWiFi-R3L-srv> References: <20200319131221.14044-1-david@redhat.com> <20200319131221.14044-4-david@redhat.com> <20200320073653.GE2987@MiWiFi-R3L-srv> <166f7f03-eda9-00a8-bd18-128898526313@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <166f7f03-eda9-00a8-bd18-128898526313@redhat.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-hyperv@vger.kernel.org, Michal Hocko , "Rafael J. Wysocki" , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, Wei Yang , linux-mm@kvack.org, Andrew Morton , Michal Hocko , linuxppc-dev@lists.ozlabs.org, Oscar Salvador Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On 03/20/20 at 10:50am, David Hildenbrand wrote: > On 20.03.20 08:36, Baoquan He wrote: > > On 03/19/20 at 02:12pm, David Hildenbrand wrote: > >> Let's use a simple array which we can reuse soon. While at it, move the > >> string->mmop conversion out of the device hotplug lock. > >> > >> Reviewed-by: Wei Yang > >> Acked-by: Michal Hocko > >> Cc: Greg Kroah-Hartman > >> Cc: Andrew Morton > >> Cc: Michal Hocko > >> Cc: Oscar Salvador > >> Cc: "Rafael J. Wysocki" > >> Cc: Baoquan He > >> Cc: Wei Yang > >> Signed-off-by: David Hildenbrand > >> --- > >> drivers/base/memory.c | 38 +++++++++++++++++++++++--------------- > >> 1 file changed, 23 insertions(+), 15 deletions(-) > >> > >> diff --git a/drivers/base/memory.c b/drivers/base/memory.c > >> index e7e77cafef80..8a7f29c0bf97 100644 > >> --- a/drivers/base/memory.c > >> +++ b/drivers/base/memory.c > >> @@ -28,6 +28,24 @@ > >> > >> #define MEMORY_CLASS_NAME "memory" > >> > >> +static const char *const online_type_to_str[] = { > >> + [MMOP_OFFLINE] = "offline", > >> + [MMOP_ONLINE] = "online", > >> + [MMOP_ONLINE_KERNEL] = "online_kernel", > >> + [MMOP_ONLINE_MOVABLE] = "online_movable", > >> +}; > >> + > >> +static int memhp_online_type_from_str(const char *str) > >> +{ > >> + int i; > > > > I would change it as: > > > > for (int i = 0; i < ARRAY_SIZE(online_type_to_str); i++) { > > > > That's not allowed by the C90 standard (and -std=gnu89). > > $ gcc main.c -std=gnu89 > main.c: In function 'main': > main.c:3:2: error: 'for' loop initial declarations are only allowed in > C99 or C11 mode > 3 | for (int i = 0; i < 8; i++) { > | ^~~ Good to know, thanks. > > One of the reasons why > git grep "for (int " > > will result in very little hits (IOW, only 5 in driver code only). > > -- > Thanks, > > David / dhildenb