Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934667AbbHDPB3 (ORCPT ); Tue, 4 Aug 2015 11:01:29 -0400 Received: from bes.se.axis.com ([195.60.68.10]:49724 "EHLO bes.se.axis.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756896AbbHDPBZ (ORCPT ); Tue, 4 Aug 2015 11:01:25 -0400 Date: Tue, 4 Aug 2015 17:01:22 +0200 Message-Id: <201508041501.t74F1MH3026171@ignucius.se.axis.com> From: Hans-Peter Nilsson To: xili_gchen_5257@hotmail.com CC: starvik@axis.com, jespern@axis.com, linux-cris-kernel@axis.com, linux-kernel@vger.kernel.org In-reply-to: (message from Chen Gang on Fri, 10 Jul 2015 23:50:07 +0200) Subject: Re: [PATCH v2] cris: arch-v10: kgdb: Add volatile for static variable is_dyn_brkp MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Transfer-Encoding: 7BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1017 Lines: 26 > 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; brgds, H-P -- 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/