forked from mikesart/inotify-info
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e177717
Showing
9 changed files
with
1,560 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
_debug/ | ||
_release/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright 2021 Michael Sartain | ||
|
||
All Rights Reserved. | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
# $@: name of the target file (one before colon) | ||
# $<: name of first prerequisite file (first one after colon) | ||
# $^: names of all prerequisite files (space separated) | ||
# $*: stem (bit which matches the % wildcard in rule definition) | ||
# | ||
# VAR = val: Normal setting - values within are recursively expand when var used. | ||
# VAR := val: Setting of var with simple expansion of values inside - values are expanded at decl time. | ||
# VAR ?= val: Set var only if it doesn't have a value. | ||
# VAR += val: Append val to existing value (or set if var didn't exist). | ||
|
||
# To use static analyzer: | ||
# http://clang-analyzer.llvm.org/scan-build.html | ||
# Ie: | ||
# scan-build -k -V --use-analyzer ~/bin/clang make | ||
|
||
NAME = inotify-info | ||
|
||
CFG ?= release | ||
ifeq ($(CFG), debug) | ||
ASAN ?= 1 | ||
endif | ||
|
||
LD = $(CC) | ||
RM = rm -f | ||
MKDIR = mkdir -p | ||
VERBOSE ?= 0 | ||
|
||
COMPILER = $(shell $(CC) -v 2>&1 | grep -q "clang version" && echo clang || echo gcc) | ||
|
||
WARNINGS = -Wall -Wextra -Wpedantic -Wmissing-include-dirs -Wformat=2 -Wshadow -Wno-unused-parameter -Wno-missing-field-initializers | ||
ifneq ($(COMPILER),clang) | ||
# https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html | ||
WARNINGS += -Wsuggest-attribute=format -Wimplicit-fallthrough=2 | ||
endif | ||
|
||
# Investigate: Improving C++ Builds with Split DWARF | ||
# http://www.productive-cpp.com/improving-cpp-builds-with-split-dwarf/ | ||
|
||
CFLAGS = $(WARNINGS) -march=native -fno-exceptions -gdwarf-4 -g2 -ggnu-pubnames -gsplit-dwarf | ||
CFLAGS += -D_LARGEFILE64_SOURCE=1 -D_FILE_OFFSET_BITS=64 | ||
CXXFLAGS = -fno-rtti -Woverloaded-virtual -Wno-class-memaccess -Wno-pedantic | ||
LDFLAGS = -march=native -gdwarf-4 -g2 -Wl,--build-id=sha1 | ||
LIBS = -Wl,--no-as-needed -lm -ldl -lpthread -lstdc++ | ||
|
||
ifneq ("$(wildcard /usr/bin/ld.gold)","") | ||
$(info Using gold linker...) | ||
LDFLAGS += -fuse-ld=gold -Wl,--gdb-index | ||
endif | ||
|
||
CFILES = \ | ||
inotify-info.cpp \ | ||
lfqueue/lfqueue.c | ||
|
||
# Useful GCC address sanitizer checks not enabled by default | ||
# https://kristerw.blogspot.com/2018/06/useful-gcc-address-sanitizer-checks-not.html | ||
|
||
ifeq ($(ASAN), 1) | ||
# https://gcc.gnu.org/gcc-5/changes.html | ||
# -fsanitize=float-cast-overflow: check that the result of floating-point type to integer conversions do not overflow; | ||
# -fsanitize=alignment: enable alignment checking, detect various misaligned objects; | ||
# -fsanitize=vptr: enable checking of C++ member function calls, member accesses and some conversions between pointers to base and derived classes, detect if the referenced object does not have the correct dynamic type. | ||
ASAN_FLAGS = -fno-omit-frame-pointer -fno-optimize-sibling-calls | ||
ASAN_FLAGS += -fsanitize=address # fast memory error detector (heap, stack, global buffer overflow, and use-after free) | ||
ASAN_FLAGS += -fsanitize=leak # detect leaks | ||
ASAN_FLAGS += -fsanitize=undefined # fast undefined behavior detector | ||
ASAN_FLAGS += -fsanitize=float-divide-by-zero # detect floating-point division by zero; | ||
ASAN_FLAGS += -fsanitize=bounds # enable instrumentation of array bounds and detect out-of-bounds accesses; | ||
ASAN_FLAGS += -fsanitize=object-size # enable object size checking, detect various out-of-bounds accesses. | ||
CFLAGS += $(ASAN_FLAGS) | ||
LDFLAGS += $(ASAN_FLAGS) | ||
endif | ||
|
||
ifeq ($(CFG), debug) | ||
ODIR=_debug | ||
CFLAGS += -O0 -DDEBUG | ||
CFLAGS += -D_GLIBCXX_DEBUG -D_GLIBCXX_DEBUG_PEDANTIC -D_GLIBCXX_SANITIZE_VECTOR -D_LIBCPP_DEBUG=1 | ||
else | ||
ODIR=_release | ||
CFLAGS += -O2 -DNDEBUG | ||
endif | ||
|
||
PROJ = $(ODIR)/$(NAME) | ||
$(info Building $(ODIR)/$(NAME)...) | ||
|
||
ifeq ($(VERBOSE), 1) | ||
VERBOSE_PREFIX= | ||
else | ||
VERBOSE_PREFIX=@ | ||
endif | ||
|
||
C_OBJS = ${CFILES:%.c=${ODIR}/%.o} | ||
OBJS = ${C_OBJS:%.cpp=${ODIR}/%.o} | ||
|
||
all: $(PROJ) | ||
|
||
$(ODIR)/$(NAME): $(OBJS) | ||
@echo "Linking $@..."; | ||
$(VERBOSE_PREFIX)$(LD) $(LDFLAGS) $^ $(LIBS) -o $@ | ||
|
||
-include $(OBJS:.o=.d) | ||
|
||
$(ODIR)/%.o: %.c Makefile | ||
$(VERBOSE_PREFIX)echo "---- $< ----"; | ||
@$(MKDIR) $(dir $@) | ||
$(VERBOSE_PREFIX)$(CC) -MMD -MP -std=gnu99 $(CFLAGS) -o $@ -c $< | ||
|
||
$(ODIR)/%.o: %.cpp Makefile | ||
$(VERBOSE_PREFIX)echo "---- $< ----"; | ||
@$(MKDIR) $(dir $@) | ||
$(VERBOSE_PREFIX)$(CXX) -MMD -MP -std=c++11 $(CFLAGS) $(CXXFLAGS) -o $@ -c $< | ||
|
||
.PHONY: clean | ||
|
||
clean: | ||
@echo Cleaning... | ||
$(VERBOSE_PREFIX)$(RM) $(PROJ) | ||
$(VERBOSE_PREFIX)$(RM) $(OBJS) | ||
$(VERBOSE_PREFIX)$(RM) $(OBJS:.o=.d) | ||
$(VERBOSE_PREFIX)$(RM) $(OBJS:.o=.dwo) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
# inotify-info | ||
|
||
The Linux inotify system has a few issues** and can be difficult to debug. | ||
|
||
This app should hopefully help track down how many inotify watches, instances, and what files are being watched. | ||
|
||
** https://code.visualstudio.com/docs/setup/linux#_visual-studio-code-is-unable-to-watch-for-file-changes-in-this-large-workspace-error-enospc | ||
*** https://unix.stackexchange.com/questions/15509/whos-consuming-my-inotify-resources | ||
|
||
## Build | ||
``` | ||
$ make | ||
Building _release/inotify-info... | ||
---- inotify-info.cpp ---- | ||
---- lfqueue/lfqueue.c ---- | ||
Linking _release/inotify-info... | ||
``` | ||
``` | ||
$ CFG=debug make | ||
Building _debug/inotify-info... | ||
---- inotify-info.cpp ---- | ||
---- lfqueue/lfqueue.c ---- | ||
Linking _debug/inotify-info... | ||
``` | ||
|
||
## Run (Prints Summary) | ||
``` | ||
$ _release/inotify-info | ||
------------------------------------------------------------------------------ | ||
INotify Limits: | ||
max_queued_events: 16384 | ||
max_user_instances: 128 | ||
max_user_watches: 65536 | ||
------------------------------------------------------------------------------ | ||
Pid App Watches Instances | ||
2632 systemd 23 3 | ||
2653 pulseaudio 2 2 | ||
2656 dbus-daemon 2 1 | ||
2987 dbus-daemon 1 1 | ||
3056 xfsettingsd 56 1 | ||
3068 xfdesktop 10 1 | ||
3072 wrapper-2.0 6 1 | ||
3091 xfce4-clipman 1 1 | ||
3099 xiccd 1 1 | ||
3343 xfce4-terminal 1 1 | ||
3997 xfce4-appfinder 11 1 | ||
4048 xdg-desktop-portal 1 1 | ||
4086 xdg-desktop-portal-gtk 56 1 | ||
205668 vivaldi-bin 8 1 | ||
205705 vivaldi-bin 2 1 | ||
------------------------------------------------------------------------------ | ||
Total inotify Watches: 181 | ||
Total inotify Instances: 18 | ||
------------------------------------------------------------------------------ | ||
``` | ||
|
||
## Run with Appname Filter | ||
``` | ||
$ _release/inotify-info xfce4 | ||
------------------------------------------------------------------------------ | ||
INotify Limits: | ||
max_queued_events: 16384 | ||
max_user_instances: 128 | ||
max_user_watches: 65536 | ||
------------------------------------------------------------------------------ | ||
Pid App Watches Instances | ||
2632 systemd 23 3 | ||
2653 pulseaudio 2 2 | ||
2656 dbus-daemon 2 1 | ||
2987 dbus-daemon 1 1 | ||
3056 xfsettingsd 56 1 | ||
3068 xfdesktop 10 1 | ||
3072 wrapper-2.0 6 1 | ||
3091 xfce4-clipman 1 1 | ||
94111050 [10304h] | ||
3099 xiccd 1 1 | ||
3343 xfce4-terminal 1 1 | ||
71048655 [10304h] | ||
3997 xfce4-appfinder 11 1 | ||
94111468 [10304h] 15339430 [10304h] 14554799 [10304h] 70254617 [10304h] 70254684 [10304h] 16786993 [10304h] 14551253 [10304h] 14550430 [10304h] 70254647 [10304h] 70254646 [10304h] | ||
92275589 [10304h] | ||
4048 xdg-desktop-portal 1 1 | ||
4086 xdg-desktop-portal-gtk 56 1 | ||
205668 vivaldi-bin 8 1 | ||
205705 vivaldi-bin 2 1 | ||
------------------------------------------------------------------------------ | ||
Total inotify Watches: 181 | ||
Total inotify Instances: 18 | ||
------------------------------------------------------------------------------ | ||
Searching '/' for listed inodes... (8 threads) | ||
14550430 [10304h] /usr/share/applications/ | ||
14551253 [10304h] /usr/local/share/ | ||
14554799 [10304h] /usr/share/xfce4/ | ||
15339430 [10304h] /usr/share/desktop-directories/ | ||
16786993 [10304h] /usr/share/xfce4/applications/ | ||
70254617 [10304h] /home/mikesart/.local/share/ | ||
70254646 [10304h] /home/mikesart/.config/menus/ | ||
70254647 [10304h] /home/mikesart/.config/menus/applications-merged/ | ||
70254684 [10304h] /home/mikesart/.local/share/applications/ | ||
71048655 [10304h] /home/mikesart/.config/xfce4/terminal/ | ||
92275589 [10304h] /etc/xdg/menus/ | ||
94111050 [10304h] /home/mikesart/.config/xfce4/panel/ | ||
94111468 [10304h] /home/mikesart/.cache/xfce4/xfce4-appfinder/ | ||
``` | ||
## Run with Specific Pid(s) | ||
``` | ||
$ _release/inotify-info 3997 | ||
------------------------------------------------------------------------------ | ||
INotify Limits: | ||
max_queued_events: 16384 | ||
max_user_instances: 128 | ||
max_user_watches: 65536 | ||
------------------------------------------------------------------------------ | ||
Pid App Watches Instances | ||
2632 systemd 23 3 | ||
2653 pulseaudio 2 2 | ||
2656 dbus-daemon 2 1 | ||
2987 dbus-daemon 1 1 | ||
3056 xfsettingsd 56 1 | ||
3068 xfdesktop 10 1 | ||
3072 wrapper-2.0 6 1 | ||
3091 xfce4-clipman 1 1 | ||
3099 xiccd 1 1 | ||
3343 xfce4-terminal 1 1 | ||
3997 xfce4-appfinder 11 1 | ||
94111468 [10304h] 15339430 [10304h] 14554799 [10304h] 70254617 [10304h] 70254684 [10304h] 16786993 [10304h] 14551253 [10304h] 14550430 [10304h] 70254647 [10304h] 70254646 [10304h] | ||
92275589 [10304h] | ||
4048 xdg-desktop-portal 1 1 | ||
4086 xdg-desktop-portal-gtk 56 1 | ||
205668 vivaldi-bin 8 1 | ||
205705 vivaldi-bin 2 1 | ||
------------------------------------------------------------------------------ | ||
Total inotify Watches: 181 | ||
Total inotify Instances: 18 | ||
------------------------------------------------------------------------------ | ||
Searching '/' for listed inodes... (8 threads) | ||
14550430 [10304h] /usr/share/applications/ | ||
14551253 [10304h] /usr/local/share/ | ||
14554799 [10304h] /usr/share/xfce4/ | ||
15339430 [10304h] /usr/share/desktop-directories/ | ||
16786993 [10304h] /usr/share/xfce4/applications/ | ||
70254617 [10304h] /home/mikesart/.local/share/ | ||
70254646 [10304h] /home/mikesart/.config/menus/ | ||
70254647 [10304h] /home/mikesart/.config/menus/applications-merged/ | ||
70254684 [10304h] /home/mikesart/.local/share/applications/ | ||
92275589 [10304h] /etc/xdg/menus/ | ||
94111468 [10304h] /home/mikesart/.cache/xfce4/xfce4-appfinder/ | ||
``` |
Oops, something went wrong.