Re: kmalloc - Crashing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Aug 18, 2021 at 06:07:26PM +0530, Lloyd wrote:
> On Wed, Aug 18, 2021 at 5:38 PM Greg KH <greg@xxxxxxxxx> wrote:
> 
> > On Wed, Aug 18, 2021 at 05:03:07PM +0530, Lloyd wrote:
> > > Hi,
> > >
> > > I am starting to write linux kernel mode code. I am on Ubuntu 20.04. I
> > have
> > > written the following code
> > >
> > > The line   DynPage[i]=0; //CRASH  causes a crash. Can you please guide on
> > > the reason for the crash?
> > >
> > > Thanks a lot in advance,
> > >   Lloyd
> > >
> > > #pragma GCC push_options
> > > #pragma GCC optimize("O0")
> >
> > Why are you using these options?  Try removing them and see what
> > happens.
> >
> >
> Thanks a lot Greg. Yes, the code works now.
> 
> The assignment inside the for loop (DynPage[i]=0) is not used
> anywhere below. I thought that, when the compiler optimizes the code, it
> can remove that line. I am writing a small benchmarking application. So, I
> don't want that line to be removed by the compiler. Is there a better way
> to achieve this?
> 
> I am also surprised to see that disabling compiler optimization for
> a function caused my code to crash!!

Be careful, and do not modify any of the existing compiler options that
the kernel uses, as they are set very specifically so that stuff like
this will not crash.

And writing benchmarks is an art, be careful to determine what you are
trying to test, and to see if what you are writing actually tests that.

good luck!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies



[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]

  Powered by Linux