Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753379AbbHEOSA (ORCPT ); Wed, 5 Aug 2015 10:18:00 -0400 Received: from blu004-omc1s3.hotmail.com ([65.55.116.14]:50495 "EHLO BLU004-OMC1S3.hotmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752622AbbHEOR6 (ORCPT ); Wed, 5 Aug 2015 10:17:58 -0400 X-TMN: [u4WUwr0GM7sle48VqrdAoCre6KzIU+hw] X-Originating-Email: [xili_gchen_5257@hotmail.com] Message-ID: Date: Wed, 5 Aug 2015 22:19:35 +0800 From: Chen Gang User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Hans-Peter Nilsson CC: starvik@axis.com, jespern@axis.com, linux-cris-kernel@axis.com, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] cris: arch-v10: kgdb: Add volatile for static variable is_dyn_brkp References: <201508041501.t74F1MH3026171@ignucius.se.axis.com> In-Reply-To: <201508041501.t74F1MH3026171@ignucius.se.axis.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 05 Aug 2015 14:17:56.0573 (UTC) FILETIME=[866130D0:01D0CF89] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1220 Lines: 34 On 8/4/15 23:01, Hans-Peter Nilsson wrote: >> From: Chen Gang >> Date: Fri, 10 Jul 2015 23:50:07 +0200 > >> Within one C file, current gcc can optimize the global static variables >> according to the C code, but it will skip assembly code -- it will pass >> them to gas directly. >> >> if the static variable is used between C code and assembly code in one C >> file (e.g. is_dyn_brkp in kgdb.c), it needs volatile to let gcc know it >> should not be optimized, or it may cause issue. > > In this case it's *mostly* a matter of taste but please avoid > using volatile as a hammer when there are other tools available. > >> -static unsigned char is_dyn_brkp = 0; >> +static volatile unsigned char is_dyn_brkp; > > Please instead use "__used", i.e. > +static unsigned char __used is_dyn_brkp = 0; > OK, thanks. I shall send patch v3 for it, next. Thanks. -- Chen Gang Open, share, and attitude like air, water, and life which God blessed -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/