[OpenWrt-Devel] [PATCH v2] procd: Add cached and available to memory table
This should allow Luci to show a better measure of system memory usage Cached memory will be used to add a new progress bar MemAvailable is the kernel's estimate of memory that is useable by userspace without swapping, and is more accurate than the current memory.free + memory.buffered calculation for total memory available Changes in v2: reorganized code to not leak a file descriptor if early return stay consistent with current comment style use atoll instead of atol to better match the data size Signed-off-by: Zachary Cook --- system.c | 29 + 1 file changed, 29 insertions(+) diff --git a/system.c b/system.c index 8ed3f93..79f0ca8 100644 --- a/system.c +++ b/system.c @@ -228,9 +228,36 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj, #ifdef linux struct sysinfo info; void *c; + char line[256]; + char *key, *val; + unsigned long long available, cached; + FILE *f; if (sysinfo(&info)) return UBUS_STATUS_UNKNOWN_ERROR; + + if ((f = fopen("/proc/meminfo", "r")) == NULL) + return UBUS_STATUS_UNKNOWN_ERROR; + + /* if linux < 3.14 MemAvailable is not in meminfo */ + available = 0; + cached = 0; + + while(fgets(line, sizeof(line), f)) + { + key = strtok(line, " :"); + val = strtok(NULL, " "); + + if (!key || !val) + continue; + + if (!strcasecmp(key, "MemAvailable")) + available = 1024 * atoll(val); + else if (!strcasecmp(key, "Cached")) + cached =1024 * atoll(val); + } + + fclose(f); #endif now = time(NULL); @@ -256,6 +283,8 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj, blobmsg_add_u64(&b, "free", info.mem_unit * info.freeram); blobmsg_add_u64(&b, "shared", info.mem_unit * info.sharedram); blobmsg_add_u64(&b, "buffered", info.mem_unit * info.bufferram); + blobmsg_add_u64(&b, "available",available); + blobmsg_add_u64(&b, "cached", cached); blobmsg_close_table(&b, c); c = blobmsg_open_table(&b, "swap"); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [PATCH] procd: Add cached and available to memory table
Hi, a few nitpicks inline... Am Montag, 11. Februar 2019, 15:00:33 CET schrieb Zachary Cook: > This should allow Luci to show a better measure of system memory usage > Cached memory will be used to add a new progress bar > MemAvailable is the kernel's estimate of memory that is useable > by userspace without swapping, and is more accurate than the current > memory.free + memory.buffered calculation for total memory available > > Signed-off-by: Zachary Cook > --- > system.c | 29 + > 1 file changed, 29 insertions(+) > > diff --git a/system.c b/system.c > index 8ed3f93..501d589 100644 > --- a/system.c > +++ b/system.c > @@ -228,6 +228,13 @@ static int system_info(struct ubus_context *ctx, struct > ubus_object *obj, #ifdef linux > struct sysinfo info; > void *c; > + char line[256]; > + char *key, *val; > + unsigned long long available, cached; > + FILE *f; > + > + if ((f = fopen("/proc/meminfo", "r")) == NULL) > + return UBUS_STATUS_UNKNOWN_ERROR; > > if (sysinfo(&info)) > return UBUS_STATUS_UNKNOWN_ERROR; f leaks in case of return here > @@ -251,11 +258,33 @@ static int system_info(struct ubus_context *ctx, > struct ubus_object *obj, blobmsg_add_u32(&b, NULL, info.loads[2]); > blobmsg_close_array(&b, c); > > + //if linux < 3.14 MemAvailable is not in meminfo please stay consistent with current style and use /* comments*/ > + available = 0; > + cached = 0; > + > + while(fgets(line, sizeof(line), f)) > + { > + key = strtok(line, " :"); > + val = strtok(NULL, " "); > + > + if (!key || !val) > + continue; > + > + if (!strcasecmp(key, "MemAvailable")) > + available = 1024 * atol(val); since "available" is unsigned long long, why not use atoll here? > + else if (!strcasecmp(key, "Cached")) > + cached =1024 * atol(val); dito > + } > + > + fclose(f); > + > c = blobmsg_open_table(&b, "memory"); > blobmsg_add_u64(&b, "total",info.mem_unit * info.totalram); > blobmsg_add_u64(&b, "free", info.mem_unit * info.freeram); > blobmsg_add_u64(&b, "shared", info.mem_unit * info.sharedram); > blobmsg_add_u64(&b, "buffered", info.mem_unit * info.bufferram); > + blobmsg_add_u64(&b, "available",available); > + blobmsg_add_u64(&b, "cached", cached); > blobmsg_close_table(&b, c); > > c = blobmsg_open_table(&b, "swap"); mhei ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] [RFC] [PATCH v2] lantiq: net: ethernet driver with fragments
Hi Petr, Now i can test new lan driver on VGV7510KW22. Its look really good, with path 904&905 i have 2-4 Mbits more bandwidth, but it seams increasing of descriptors not enough to resole ring full events. Test bench: * O2 box (VGV7510KW22) are connected on 1 GBit switch. * Openwrt master (initramfs) with bootargs = "console=ttyLTQ0,115200"; * Boot via TFTP * disabled: dsl_control, odhcpd, dnsmasq See logs. I will test this 2 pathes on BT5 next days Best regards Yaro On 2/8/19 2:10 PM, Petr Cvek wrote: I think I've managed to fix the backported driver from vanilla kernel. I forgot to copy phy_start() call from original driver (that's probably why it didn't work, I'm booting from NFS and from port 0, so it was enabled already) and I've added the support for the skb fragments. This seems to greatly increase the TX throughput. In the addition it seems the DMA burst patch doesn't increase the throughput anymore (TX is probably saturated now, and the code is better), but the driver supports any burst mode now anyway (there was just a problem with buffer alignment). There were ring full events often, so I've increased the number of descriptors from 0x40 to 0xc0 and changed the timeout. Maybe it should work better if the queue is stopped around 50% or something like that. Attached: 0904... - new driver 0905... - descriptor increase run.sh - testing script, various iperf3 modes vanilla... - vanilla openwrt test z4_hyst... - new driver test (measured with previous patches for SMP ICU and burst) Petr ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel -- Mit freundlichen Grüßen, Yaroslav Petrov -- Best regards Yaroslav Petrov -- С уважением Петров Ярослав email: i...@lank.me mob DE: +49 151 521 99000 (WhatsApp) [ 47.336391] br-lan: port 1(eth0.1) entered disabled state [ 47.342409] device eth0.1 entered promiscuous mode [ 47.346567] device eth0 entered promiscuous mode [ 47.357298] IPv6: ADDRCONF(NETDEV_UP): br-lan: link is not ready [ 50.383706] lantiq,xrx200-net 1e108000.eth eth0: port 3 got link [ 50.388530] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready [ 50.395767] br-lan: port 1(eth0.1) entered blocking state [ 50.44] br-lan: port 1(eth0.1) entered forwarding state [ 50.406444] IPv6: ADDRCONF(NETDEV_CHANGE): br-lan: link becomes ready root@OpenWrt:/# cat /proc/interrupts CPU0 CPU1 7: 151484 152800 MIPS 7 timer 8: 1448 332285 MIPS 0 IPI call 9: 3967 21752 MIPS 1 IPI resched 62: 0 0 icu 62 1e101000.usb, dwc2_hsotg:usb1 63: 2614 0 icu 63 mei_cpe 72: 453795 0 icu 72 vrx200_rx 73: 634185 0 icu 73 vrx200_tx 75: 0 0 icu 75 vrx200_tx_2 112: 4041 0 icu 112 asc_tx 113:386 0 icu 113 asc_rx 114: 0 0 icu 114 asc_err 126: 0 0 icu 126 gptu 127: 0 0 icu 127 gptu 128: 0 0 icu 128 gptu 129: 0 0 icu 129 gptu 130: 0 0 icu 130 gptu 131: 0 0 icu 131 gptu 150: 0 0 icu 150 mps_mbx vc0 151: 0 0 icu 151 mps_mbx vc1 152: 0 0 icu 152 mps_mbx vc2 153: 0 0 icu 153 mps_mbx vc3 154: 0 0 icu 154 mps_mbx ad0 155: 0 0 icu 155 mps_mbx ad1 ERR: 0 root@OpenWrt:/# + : ':::[' configuration openwrt_master ']:::' : + iperf3 -c 192.168.1.133 Connecting to host 192.168.1.133, port 5201 [ 4] local 192.168.1.51 port 56710 connected to 192.168.1.133 port 5201 [ ID] Interval Transfer Bandwidth Retr Cwnd [ 4] 0.00-1.00 sec 11.1 MBytes 92.8 Mbits/sec0206 KBytes [ 4] 1.00-2.00 sec 10.0 MBytes 83.9 Mbits/sec0206 KBytes [ 4] 2.00-3.00 sec 11.0 MBytes 92.3 Mbits/sec0206 KBytes [ 4] 3.00-4.00 sec 10.8 MBytes 90.7 Mbits/sec1160 KBytes [ 4] 4.00-5.00 sec 11.2 MBytes 94.3 Mbits/sec0198 KBytes [ 4] 5.00-6.00 sec 11.2 MBytes 93.8 Mbits/sec0199 KBytes [ 4] 6.00-7.00 sec 10.3 MBytes 86.0 Mbits/sec0199 KBytes [ 4] 7.00-8.00 sec 10.2 MBytes 85.5 Mbits/sec2175 KBytes [ 4] 8.00-9.00 sec 10.4 MBytes 87.6 Mbits/sec0198 KBytes [ 4] 9.00-10.00 sec 10.6 MBytes 88.6 Mbits/sec0199 KBytes - - - - - - - - - - - - - - - - - - - - - - - - - [ ID] Interval Transfer Bandwidth Retr [ 4] 0.00-10.00 sec 107 MBytes 89.6 Mbits/sec3
[OpenWrt-Devel] netdevconf + ietf airbnb share in prague?
I might be going to either or both of these conferences. I am curious if anyone else is going and would like to split an airbnb? https://netdevconf.org/0x13/ has quite a lot of interest to openwrt folk - in my case the wireless workshop, bpf, and l4s talks are of note. I've got a talk at netdevconf *maybe* on opening up the 240/4 IPv4 address space. Netdevconf is march 20-22nd, ietf is 23- ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
Re: [OpenWrt-Devel] ar71xx: OM2P ImageBuilder no firmware when BIN_DIR used
On Friday, 1 February 2019 13:03:42 CET Paul Spooren wrote: > Hi all, > > thanks to this[0] bug report I found that the ar71xx/generic > ImageBuilder doesn't create any firmware images for profile OM2P when > used with BIN_DIR. > > My first guess is that it's somewhat related to a hard coded destination > which doesn't handle BIN_DIR. At the very end of an "successful" build log: > > > if [ -e > > "/home/aparcar/worker/imagebuilder/openwrt/18.06.2/ar71xx/generic/bin/targets/ar71xx/generic/openwrt-18.06.2-c9d037b0992cca4-ar71xx-generic-om2p-squashfs-factory.bin" > > ]; then cp > > "/home/aparcar/worker/imagebuilder/openwrt/18.06.2/ar71xx/generic/bin/targets/ar71xx/generic/openwrt-18.06.2-c9d037b0992cca4-ar71xx-generic-om2p-squashfs-factory.bin" > > > > "/home/aparcar/worker/imagebuilder/openwrt/18.06.2/ar71xx/generic/bin/targets/ar71xx/generic/openwrt-18.06.2-c9d037b0992cca4-ar71xx-generic-om2p-squashfs-sysupgrade.bin"; > > fi Ehrm, no. These things are not hardcoded but your make just filled the placeholders before it prints it and sends it to your $SHELL. The legacy build script is basically calling this helper: define Image/Build/OpenMesh -sh $(TOPDIR)/scripts/om-fwupgradecfg-gen.sh \ "$(4)" \ "$(BUILD_DIR)/fwupgrade.cfg-$(4)" \ "$(KDIR_TMP)/vmlinux-$(2).uImage" \ "$(KDIR)/root.$(1)" -sh $(TOPDIR)/scripts/combined-ext-image.sh \ "$(4)" "$(call factoryname,$(1),$(2))" \ "$(BUILD_DIR)/fwupgrade.cfg-$(4)" "fwupgrade.cfg" \ "$(KDIR_TMP)/vmlinux-$(2).uImage" "kernel" \ "$(KDIR)/root.$(1)" "rootfs" if [ -e "$(call factoryname,$(1),$(2))" ]; then \ cp "$(call factoryname,$(1),$(2))" "$(call sysupname,$(1),$(2))"; \ fi endef The output files are defined using: define sysupname $(call imgname,$(1),$(2))-sysupgrade.bin endef define factoryname $(call imgname,$(1),$(2))-factory.bin endef And the imgname is: define imgname $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(call rootfs_type,$(1)) endef At least it looks to me like BIN_DIR is used. But yes, the second parameter to scripts/combined-ext-image.sh in the make output is really using something which is definitely not containing the user supplied BIN_DIR but the standard BIN_DIR from rules.mk. If you replace the factoryname with imgname in this line (or directly $(BIN_DIR)), you will also see that it is not using the user supplied BIN_DIR. You can also see this problem when you select "Linksys WRT400N" or "Zcomax ZCN-1523H-5-16" - which are also using factoryname/imgname. But also devices like "ALFA AP96"/"Atheros AP96", which are using the default "RKuImage", have this problem. Something tells me that all(?) legacy build scripts are affected. At least it works fine with ap121f from the non-legacy devices. I would guess that this is caused by the way SingleProfile is defined and how it interacts with LegacyDevice (include/image-legacy.mk) vs. Device (include/image.mk). If you look carefully, you will notice that legacy devices spawn a new sub-make - non-legacy devices don't do that. You can try the attached mini-patch [1] to check whether this is your problem. Kind regards, Sven [1] https://github.com/openwrt/openwrt/pull/1815From: Sven Eckelmann Date: Mon, 11 Feb 2019 16:26:42 +0100 Subject: build: Accept BIN_DIR parameter for legacy-images BIN_DIR can be set to overwrite the output path for new images. This is an advertised feature for the imagebuilder and is used by systems like LibreMesh's chef. The legacy images are build using a new sub-make which doesn't receive the variable overwrites of the parent make process. As result, the BIN_DIR is automatically defined to the default value from rules.mk. The images will therefore not be placed in the output path which was selected by the user. Providing BIN_DIR as an explicit variable override to the sub-make works around this problem. Fixes: 26c771452cd8 ("image.mk: add LegacyDevice wrapper to allow legacy image building code to be used for device profiles") Reported-by: Paul Spooren Signed-off-by: Sven Eckelmann diff --git a/include/image.mk b/include/image.mk index a2b106d909831411c99a725c959c05f1df912ec9..b01cd2bf6848ebdba90f87850a9e9cbdad4233e5 100644 --- a/include/image.mk +++ b/include/image.mk @@ -581,7 +581,7 @@ define BuildImage $(call Image/Prepare) legacy-images-prepare-make: image_prepare - $(MAKE) legacy-images-prepare + $(MAKE) legacy-images-prepare BIN_DIR="$(BIN_DIR)" else image_prepare: @@ -605,7 +605,7 @@ define BuildImage legacy-images-make: install-images $(call Image/mkfs/ubifs/legacy) - $(MAKE) legacy-images + $(MAKE) legacy-images BIN_DIR="$(BIN_DIR)" install: install-images $(call Image/Manifest) signature.asc Description: This is a digitally signed message part. __
[OpenWrt-Devel] moving firewall package to nftables
There are some features in nft that we'd like to use in CIRALabs' SecureHomeGateway project. In particular, it's much easier to get statistics out of nft in JSON. nft is easy to install, but it seemed that we really needed the updated iptables commands, and I upgraded that (and libnftnl, which seems to require a git head to work with iptables iptables 1.8.2. 1.1.2 is not new enough) I had a small hope that /sbin/fw3 was shelling out to /sbin/iptables to do it's work, but I see now that it's not the case. It uses libiptc and ip6tc directly.I have not yet investigated how hard it will be to upgrade to the nft libraries to do this. Before I continue, I wanted to check if someone else has been down this path already and determined it is premature, or if there are larger architectural issues that need to be resolved of which I am ignorant. -- ] Never tell me the odds! | ipv6 mesh networks [ ] Michael Richardson, Sandelman Software Works|IoT architect [ ] m...@sandelman.ca http://www.sandelman.ca/| ruby on rails[ signature.asc Description: PGP signature ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel
[OpenWrt-Devel] [PATCH] procd: Add cached and available to memory table
This should allow Luci to show a better measure of system memory usage Cached memory will be used to add a new progress bar MemAvailable is the kernel's estimate of memory that is useable by userspace without swapping, and is more accurate than the current memory.free + memory.buffered calculation for total memory available Signed-off-by: Zachary Cook --- system.c | 29 + 1 file changed, 29 insertions(+) diff --git a/system.c b/system.c index 8ed3f93..501d589 100644 --- a/system.c +++ b/system.c @@ -228,6 +228,13 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj, #ifdef linux struct sysinfo info; void *c; + char line[256]; + char *key, *val; + unsigned long long available, cached; + FILE *f; + + if ((f = fopen("/proc/meminfo", "r")) == NULL) + return UBUS_STATUS_UNKNOWN_ERROR; if (sysinfo(&info)) return UBUS_STATUS_UNKNOWN_ERROR; @@ -251,11 +258,33 @@ static int system_info(struct ubus_context *ctx, struct ubus_object *obj, blobmsg_add_u32(&b, NULL, info.loads[2]); blobmsg_close_array(&b, c); + //if linux < 3.14 MemAvailable is not in meminfo + available = 0; + cached = 0; + + while(fgets(line, sizeof(line), f)) + { + key = strtok(line, " :"); + val = strtok(NULL, " "); + + if (!key || !val) + continue; + + if (!strcasecmp(key, "MemAvailable")) + available = 1024 * atol(val); + else if (!strcasecmp(key, "Cached")) + cached =1024 * atol(val); + } + + fclose(f); + c = blobmsg_open_table(&b, "memory"); blobmsg_add_u64(&b, "total",info.mem_unit * info.totalram); blobmsg_add_u64(&b, "free", info.mem_unit * info.freeram); blobmsg_add_u64(&b, "shared", info.mem_unit * info.sharedram); blobmsg_add_u64(&b, "buffered", info.mem_unit * info.bufferram); + blobmsg_add_u64(&b, "available",available); + blobmsg_add_u64(&b, "cached", cached); blobmsg_close_table(&b, c); c = blobmsg_open_table(&b, "swap"); -- 2.20.1 ___ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel