yashsingh1/xdaforums huggingface dataset:
[Galaxy S II Android Development] Giobio:
Yesterday I read the whole thread, but I'm both noob about linux than unable to translate a few technical words as trim and other. And read lots of threads but no one useful for me or for my skill.

I like to have a most performance device so I'm hoping to find a user friendly guide which averyone could use(I'm refferring to ext4 for example and thanks again to mparus). But there are only einstein in the forum and it seems done for them.... Yesterday you told me to use onother thread to make other kind of questions but you spent so many pages of this thread to explain to others out-thread stuffs.

Anyway, I' ll contiunue to follow you tryin at tha same time to improve myself.
[Galaxy S II Android Development] mparus:
Some benchmark

/data trim device

/data without trim - devices with default CM11 kernel

/data immediately after trim and reboot

/data immediately after trim and reboot when I remove discard mount option

mount -o remount,rw,seclabel,nosuid,nodev,noatime,errors=panic,user_xattr,barrier=1,journal_async_commit,data=ordered,noauto_da_alloc,nodiscard -t ext4 /dev/block/mmcblk0p10 /data
[Galaxy S II Android Development] Lanchon:
>ok, I must manually run this command :(

"The Android framework will send out a “start idle maintenance window” event that the MountService listens for, and then invokes vold to fstrim filesystems when a few conditions have been met – the device hasn’t been touched for over an hour, no idle maintenance window event has been sent in 24 hours, and the device is either off-charger with 80% battery or on-charger with 30% battery. The goal is to have fstrim run roughly once every 24 hours if you’re in the habit of plugging the device in to charge every night."

i don't know why trim is not auto invoked in your case. on other people S2's it works.

>sdcard not autotrim, why?

i dont know. maybe auto trim skips vold managed mounts? you could look it up in the android code.
[Galaxy S II Android Development] Lanchon:
unfortunately this is not very useful. it takes a long time and use for an SSD to get slow without trim. people using CM's kernels for months or years will see their performance go progressively worse, and will see a big difference after trim. if you just flash back stock kernel, you'll still have the file systems recently trimmed and you'll have no performance degradation.

it would have been a good idea to benchmark BEFORE ever trimming.

wtf!! thats a bug! auto trimmed partitions in android 4.3 and after should NOT be mounted with discard.

this will make the device possibly perform worse on deletes. it's better to remove the discard mount option.

EDIT: entered in gerrit

http://review.cyanogenmod.org/#/c/72172/
[Galaxy S II Android Development] Lanchon:
i'm sorry, this is a development thread.
[Galaxy S II Android Development] mparus:
Ok but benchmark nr 2 - phone my colleague - never not trimmed
[Galaxy S II Android Development] Lanchon:
maybe he used a non CM kernel recently. write performance should suffer a lot if not trimmed. that phone doesnt look like it needed trimming. maybe your colleague never used much of the internal sdcard, i dont know.
[Galaxy S II Android Development] minek124:
does the 'discard' flag works with unpatched kernel ?

My andro bench results Neatrom 6.4 Apolo regular 4.14 (unpatched) in attachment.
[Galaxy S II Android Development] Lanchon:
no trim works with any unpatched CYANOGENMOD kernel under any circumstance with any method
[Galaxy S II Android Development] mparus:
Regardless of benchmarks rom with trim runs faster and smoother.
[Galaxy S II Android Development] Lanchon:
JB stock kernel trims when wiping data in recovery. bootloader could maybe trim when using odin, maybe. other stock derived kernels might enable trim. so flashaholics may trim without knowing, and wont notice a big impact. but after using CM for long enough, trimming should make a big difference.
[Galaxy S II Android Development] Acid0057:
Lanchon its kinda scary when you go to download the kernel and in the filename it says this file will brick your device. Is the download okay for CM 11 M9?
[Galaxy S II Android Development] Lanchon:
lol yes! i just wanted to make sure people read the OP and knew what they were doing. anyway, its kinda tested now, no one had trouble, and the way i understand it, no one should. but... standard disclaimers apply :)
[Galaxy S II Android Development] Lanchon:
M10 will come out with a friendlier name i promise :)
[Galaxy S II Android Development] Acid0057:
Fair enough. Well it worked with me, even after I confirmed that my chip doesn't suffer from any of the bugs.
[Galaxy S II Android Development] Lanchon:
so how dd it go?
[Galaxy S II Android Development] Acid0057:
Oh sorry I ment you're note worked to stop me. Then I decided to wait till you have the M10 build ready. My S2 is about two years old with heavy usage. I'm interested to see how much trim might help. Thankfully I don't have any of the emmc chips affected by the bug. It'd be the perfect phone if it didn't have that crazy fuse bug.
[Galaxy S II Android Development] Lanchon:
then you have nothing to loose! if you are running M9 go ahead and flash it now, it takes 2 seconds, no reason not to.
[Galaxy S II Android Development] Acid0057:
Nah I'm going to wait till you have M10 ready. I'm not a flashaholic :)
[Galaxy S II Android Development] Lanchon:
rewritten OP. updated it and prepared it for other devices and CM versions.
[Galaxy S II Android Development] lastbronx:
I re partitioned using guide at the bottom of OP

flashed CM

flashed patched kernel

lagfix. enabled ART. Phone is fast indeed

But formatting internal ( sdcard0 ) from recovery is not doing anything. and i am also unable to format it from windows. Please help.
[Galaxy S II Android Development] Lanchon:
you crossposted with your PM!
[Galaxy S II Android Development] 3dawg:
this-will-hard-brick-your-device--kernel-cm-11-20140827-UNOFFICIAL-Lanchon-11-M9-TRIM-i9100.zip

Why the hell would you call it that? Is that a joke or serious?

Typical XDA...
[Galaxy S II Android Development] Zile995:
Serious [emoji35] [emoji1]
[Galaxy S II Android Development] gadam40:
It works on other roms based on cm11? I must have only CM to use that?
[Galaxy S II Android Development] 3dawg:
Your Emoji don't show up on desktop. Could I just have a straight answer please? "Safe" or not?
[Galaxy S II Android Development] Lanchon:
read the OP then decide, never mind about the name, its to discourage flashing without reading
[Galaxy S II Android Development] Lanchon:
M9 kernel is for CM M9 specifically. other configurations not guaranteed to work.
[Galaxy S II Android Development] ajislav:
Finally found the time to do it.

1) flashed your M9 kernel on VYL00M 0x19 (brickbug). Kernel works even though I was on 20140829 nightly

2) lagfix

3) profit !!! (can't say I feel significant difference, but even placebo feels good)

4) flashed back a newer nightly and waiting for M10 and your kernel, Lanchon

Many thanks
[Galaxy S II Android Development] Lanchon:
note that going from a recent nightly to an M usually means you are downgrading.
[Galaxy S II Android Development] Lanchon:
UPDATES:

-kernels released for other devices !!!

-important edits in the OP
[Galaxy S II Android Development] Jigen90:
I want to share my feedback.

My I9100 comes with VYL00M fwrev 0x19, and I decided to flash this kernerl.

I come from a CM11 M9 with gustavo kernel (it's a official cm kernel with some additions).

Well, after I flashed Lanchon kernel at 1st boot Wi-Fi was working.

I installed LagFix app and decide to trim system, data cache; it took almost 30 secods to complete its job. (data partition took most of the time)

Then I rebooted to profit!

When CM completely booted up I noticed Wi-Fi wasn't working anymore (I wasn't able to turn it on).

So I tried to flash my previous kernel, gustavo.

I went to recovery, but Lanchon kernel wasn't able to install zip from sdcard0 nor sdcard1. It failed mounting both sdcards.

I tried to reboot, no way; while from CM both cards were readable.

I turned on Odin and flashed another kernel directly, just to be able to flash again zip files from sdcards.

To summarize:

1) Wi-Fi I think it's not completely working

2) I found some problems in recovery, mounting sdcards or trying to install from sdcards

3) I noticed a tiny improvement after trim. A little bit snappy while multi tasking.

I'm looking forward to see new improvements and fixes! :good:
[Galaxy S II Android Development] Lanchon:
thanks for your feedback.

you come from an unsupported configuration, not official M9. also, i dont know about gustavos, for all i know the kernel could support trim and you'd see no difference. but i doubt it.

it is a well known bug that sometimes the wifi doesnt turn on. this is yet another face of the "music bug", see the section on 10.1.3 in the OP. if you had rebooted, it would have been ok.

regarding the problems in recovery, thats strange. maybe your download was corrupted. or somehow you phone corrupted the flash (it can: WL bug (you have it, no matter what the table says), music bug). or the state of your phone is unsupported.

flash official M9 kernel, try the recovery. then flash my kernel and see if the recovery has any problem that the official doesnt. please check the MD5 of the download before flashing.

fyi, no one else reported the problems you report.
[Galaxy S II Android Development] Lanchon:
UPDATE: new CM 10.1.3 kernels that make /preload writable and mount /cache, /data and /preload with the discard option.
[Galaxy S II Android Development] Lanchon:
UPDATE: the M10 TRIM-capable kernel is out, just minutes after the release of official CM11 M10 :)

this release mounts /data without the discard option for increased performance.
[Galaxy S II Android Development] vyp54:
I was just going to ask about M10 compatible kernel. I'm flashing M10 now and your kernel after.

My S2 has sane chip and no bug, so there's less chance of bricking it after flashing your kernel? If I understood correctly.

EDIT: I forgot that kernel and recovery are one on S2. So how do I flash a CM M10 and your kernel? What goes first? S3 is nothing like this. -.-
[Galaxy S II Android Development] Lanchon:
lol. no risk. instructions in OP.
[Galaxy S II Android Development] vyp54:
Is there a .tar version of your kernel so I can flash it along with repartition and then CM M10 after?
[Galaxy S II Android Development] Lanchon:
no, but theres a link in the OP telling you how to make my kernel into a tar. its extremely simple. alternatively, odin any suitable kernel, then flash CM, then my kernel.
[Galaxy S II Android Development] vyp54:
Thanks, I've managed to get it running. Nice work, the device is flying now. :cool:
[Galaxy S II Android Development] Lanchon:
wow trim bug!!!!

(readers note: this is NOT an i9100, this post is in the wrong thread)

ok, my kernel contains the patch named here:

http://wiki.cyanogenmod.org/w/EMMC_Bugs#MAG2GA_TRIM_bug

-the Nook HD+s with this eMMC and no kernel patch have been reportedly bricking when trim is invoked.

-but the 2012 Nexus 7s have this chip with an even older firmware (v05 instead of v06, so the assumption is that the bug is there too) and DO NOT BRICK WITH TRIM. (google's stock 4.3 android update trims these devices every night.)

so the understanding is that the kernel patch found in google's stock 4.3 (inlcuded in my kernel too) fixes the issue (at least for the v05 firmware),

the patch uses a different eMMC command for trimming: discard instead of trim. discard is a newer command (defined in a newer eMMC spec) that is easier for the eMMC to implement (and for that reason can be faster) but basically fulfills the same function.

so it looks like this bug affects the eMMC trim command but not discard. and with this patch, by always invoking discard instead of trim, the stock Nexus 7 2012 can happily trim away without any of them having ever bricked.

i believe that the same thing applies to your device, ie: i believe my kernel is safe. again i repeat, it *has* this patch.

but still, trimming this eMMC in the d710 is untested (even though in the nexus 7 is fully tested to be safe). so there's always some risk in the unknown. please read this post twice and decide if you want to test. please post your experience.

(user [MENTION=5709515]xxfirefurryxx[/MENTION] seems to be in the same situation.)
[Galaxy S II Android Development] tftd:
I can concur - the mod works fine, although I had the supposedly "brickable" version of my S2 i9100. LagFix took around 40 seconds to complete on all partitions. The screenshots below show the results from AndroBench:

After I ran LagFixer I must say my device started running a little bit faster. Will see how things workout in the next couple of days.
[Galaxy S II Android Development] Lanchon:
thanks for the benchmarks. too bad we didnt get treated to before and after benchs :)

you should find less lag and hiccups and more responsiveness, especially with background tasks running. too bad i dont have a device so i dont really know first hand.

thanks again for the shots!
[Galaxy S II Android Development] smoke2tun:
Thank you for the kernel

I've been using CM M10 and then your kernel for two days now.

The phone is realy snappy and responsive. I never encountered the wi-fi bug until now.

After runing Antutu v5.1 the overall score is 17816. On NeatRom the score had an average of 11000.

I have a sane chip.

Type: V3U00M

Date: 09/2012

FwRev: 0x0e
[Galaxy S II Android Development] Lanchon:
thanks, glad to know! although a fair comparison would have been against vanilla CM11 *before* ever trimming. btw, you may want to give ART a try.
[Galaxy S II Android Development] smoke2tun:
Coming from NeatRom i had to do a clean install and in that process i've formated all partitions. Further more i have used a pit file with 1GB system, 6 GB Data and small preload. So after i've flashed CM11 with stock kernel my partitions were allready "trimmed". To do a relevant Antutu test with stock kernell i should have used my phone for at least a week so my system and data partition became fragmented.

In the future i will switch to ART and report back.
[Galaxy S II Android Development] Lanchon:
no, they weren't. for all i know partitioning does not touch the partition contents, only the partition table. in part thats why formatting is needed afterwards only in partitions that changed their storage extent (others untouched).

and formatting does not trim, unless you do it with a trim capable kernel like mine.
[Galaxy S II Android Development] defecat0r:
Indeed, I see a lot of people getting a bit confused about this. A characteristic of all flash memory (usb stick, sd card, ssd drive, phone mmc) is that the low level memory blocks need to be physically set to certain "erased" state by the memory's controller chip before it can be written to again. This 'erase' funtion is called in two ways: 1/ done immediately before data is written as part of the write command (which is why our phones are so slow), or 2/ when called by the trim function so that the slow 'erase' process is done in down time, meaning that when data needs to be written, writing is the ONLY thing it needs to do.

Even COMPLETELY formatting and repartitioning your phone will have no affect on this. Formatting is a much higher level operation affecting only the system's file allocation tables, this 'erase' function is a low level thing done by the emmc's controller.

That might not be 100% but that's how i understand it and it makes sense to me :)

Thanks for your magnificent work Lanchon, much respect. I'm in the process of backing up my n7000 now before I throw on your cm11 fix. So sick of this laggy piece of crap, great to see there's finally a fix :)
[Galaxy S II Android Development] Lanchon:
lol, hope it goes well :) get a before benchmark please!

yes, thats all true, except that there is much more than just erasing needed. there is garbage collection (due to a big mismatch of write and erase block sizes) and wear leveling (due to limited write cycle life). this results in write amplification, a phenomenon by which the eMMC has to physically erase and write many times the amount of info you asked it to write. write amplification factors of 5 or 10 times are not uncommon in old untrimmed flash storage; thats when the lags get nasty.
[Galaxy S II Android Development] Spyr0s:
Is there a chance to see this on paranoid rom? Paranoid legacy is being released every week so it will be easier to maintain.
[Galaxy S II Android Development] Lanchon:
the hope is that device maintainers catch on this experience, reimplement trim and finally put this old subject to rest.

devices with "trim bug" still need to be tested to put the final nail in the coffin; volunteers wanted.

in the meantime i wont provide patches for any other rom. testing can be done with just one. sorry about that.
[Galaxy S II Android Development] Spyr0s:
It will never happen.
[Galaxy S II Android Development] jmsilva22:
Sorry for posting in the wrong thread, I just wanted to see what is this all about. My phone has most of the symptoms you have described before (lag, hiccups, etc) and I think it has to do with that TRIM issue. I had this phone for one and a half years and it always ran smooth with or without custom roms. Despite the risks I want to know where to find and how to run the patch -in case- I decide to do it. I went to the wiki/github links but honestly I don't understand what Im looking at.
[Galaxy S II Android Development] Lanchon:
no prob about the thread. go to the first post of *this* (i9100) thread and read it.

it has Instructions and Downloads sections.

btw, the thread for discussion of d710 users is here:

http://xdaforums.com/epic-4g-touch/development/kernel-trim-speed-cyanogenmod-galaxy-s2-t2875737

it directs people to read the first post of this i9100 thread :)

as explained on that thread, the d710 does not have M snapshots yet, so i did a nightly instead. it is here:

https://www.androidfilehost.com/?w=files&flid=19084

that kernel works specifically for THAT nightly. you should never downgrade cyanogenmod without wiping, so if you are on a newer nightly this creates a problem, as you can't go back to the right one.

in practice, though unsupported, my kernel should work fine with a newer nightly

however downgrading CM is a real problem.

so if you are on a newer nightly, prefer to flash my kernel atop the newer nightly over downgrading CM.

i think the 'perfect' solution (downgrade with full wipe) would be overkill. and should you have problems with the mixed kernel and CM versions, i could always create a kernel specific for you nightly.
[Galaxy S II Android Development] Lanchon:
what makes you say that? i think the CM maintainer of one of the kindles already went for it,
[Galaxy S II Android Development] Spyr0s:
Because they haven't implemented other tested things like BLNWW, they are weirdos.
[Galaxy S II Android Development] jmsilva22:
thank you so much for taking the time to explain further
[Galaxy S II Android Development] Lanchon:
lol! they are limited in maintainer manpower, especially since omnirom's split.
[Galaxy S II Android Development] Spyr0s:
First you will have to submit it to gerrit by yourself then you will be kicked in the teeth. Try and see by yourself ;)
[Galaxy S II Android Development] Lanchon:
lol just the other day i made a gerrit entry, bugfix for longstanding bug, and a stupid big argument ensued :) but today it got merged, so that sort of worked.

this has to be handled differently. the maintainer has to be invited over and he has to see the evidence for safety. too bad Entropy512 left CM, he was familiar with all this mess. maybe he will implement this changes in omni. but there will be resistance, and no distro will want to be the first and take the heat if something goes wrong.

for now, devices with trim bug still need to be tested.
[Galaxy S II Android Development] Lanchon:
MAG2GA TRIM Bug

---------------------------

it so happens that certain Nook HDs have the same chip, so we have info after all.

and because the nooks got so slow, someone did a trimming kernel for them. :)

apparently only rev 05 has the bug, and it's fixed in rev 06 (you have rev 0E (0E is 14 in decimal)).

people report running the trimming kernel without problems on 06:

http://xdaforums.com/showthread.php?p=48522684

(yes, my kernel has the same patch from the google nexus 7 they are talking about.)

so we KNOW rev 05 is safe to trim WITH PATCH, because the stock nexus 7 on android 4.3 trims by default (with patch).

we also know rev 06 is safe to trim with patch from experience (see above) and probably without it too, since apparently the bug only affects 05.

and presumably later revs are ok.

we also know that once the patch made it to mainline cyaongenmod 10.2 (android 4.3), there were no more bricks:

http://xdaforums.com/showthread.php?t=2648431

so..........

i'd say it's safe to try the kernel in your device:

1) it would be safe in rev05, since it has nexus 7 patch, and that has been extensively tested.

2) it would be safe in rev06, since in rev06 bug was apparently fixed. (if it wasn't, the patch is still there so it should be safe. plus it has been tested to be safe.)

3) presumably later revs have the rev06 fix. (and if not, the patch is still there for them.)

that is as much info i could find on the subject.

(btw [MENTION=5709515]xxfirefurryxx[/MENTION], you have the same eMMC.)
[Galaxy S II Android Development] g3lux:
Sucess trim

Hi. I tried this on my phone and i worked. My emmc chip:

Type: VYL00M

Date: 05/2011

FwRev: 0x19

Insane Chip

I was using spirit rom v1.3 when i saw this thread, my phone wasn't soo slow, but wanted to try this anyway.

I repartitioned my phone to 1GB /system, 4GB /data, rest internal storage. (I tried to use 6GB /data, but if i use it i can't get back internal storage, don't know why).

I followed the instructions with Cyanogenmod11 M10, and worked but i didn't like cyanogenmod because the lack of features i used with spirit rom.

So i saw that Spirit Rom was updated to v1.4, which is based on 11-20140922-UNOFFICIAL-i9100 and I flashed the trim kernel for CM11 M10 (i think that spirit rom v1.4 is based on CM11 M10, but unofficial) and it worked.

After booting installed fstrim, and trimmed /system, /data, /cache, one last reboot and success.

I ran Android Bench and i noticed a slight boost on the write speed, and on read speed, but kernel is stable, wifi is working ok.
[Galaxy S II Android Development] Lanchon:
i didnt make the PIT files, i just linked them; some might be buggy. theres a tool to make your own.

they could have patched the kernel and some of the features might be unavailable.
[Galaxy S II Android Development] g3lux:
Yes, but i saw guys in this thread http://xdaforums.com/galaxy-s2/development-derivatives/mod-partition-internal-memory-app-t2538947/ that had success with 6GB /data but i can't get it working.

I am satisfied with 4GB /data because i have still 2.13GB of /data free.

Now the kernel should trim automatically everyday wright?

they could have patched the kernel and some of the features might be unavailable.?
[Galaxy S II Android Development] Lanchon:
i suppose it should trim automatically. i dont know spirit rom. you can check the logs. read this thread for details.

spirit rom v1.4 may include a patched kernel for extra functionality. obviously these features wont work with my kernel.
[Galaxy S II Android Development] g3lux:
Yes, hopefully this trim feature gets mainstream, either on apolo kernel or gustavos kernel.

Is this kernel safe to do wipe data/factory reset? Or should i flash rom on top to replace recovery?
[Galaxy S II Android Development] Lanchon:
it is safe. it should do more than common recoveries though: it should actually wipe the data from the emmc (as opposed to standard recoveries that simply do a recoverable 'quick format') and fully trim the partition.

this functionality is untested (i dont have a device). but safety-wise, i can assure you there's no increased risk over running lagfix with my kernel.

in the i9100, kernel and recovery are bundled and flashed together. you cannot replace the recovery without replacing the kernel.